首页 > 代码库 > 跨域解决请求限制(script标签)(热门搜索出现对应的词条)

跨域解决请求限制(script标签)(热门搜索出现对应的词条)

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>热门搜索</title>
</head>
<style>
  ul{
    list-style: none;
    color:pink;
  }
</style>
<body>
  <form action="">
    <input type="text" class="search" id= ‘search‘ placeholder="请输入关键字">
    <ul id= "search-list"></ul>
  </form>
</body>
<script>
  function searchResult(json){
    var oUl = document.getElementById(‘search-list‘);
    var search = document.getElementById(‘search‘);
    oUl.innerHTML = ‘‘;
    var res = json.s;
    var len = res.length;
    for(var i = 0;i < len ;i++){
      var oNewLi = document.createElement(‘li‘);
      oNewLi.innerHTML = res[i];
      oUl.appendChild(oNewLi);
    }
  }
  window.onload = function(){
    var oInput = document.getElementById(‘search‘);
    oInput.onfocus = function(){
      this.value = http://www.mamicode.com/‘‘>

  

跨域解决请求限制(script标签)(热门搜索出现对应的词条)