zoukankan      html  css  js  c++  java
  • 跨域解决请求限制(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 = ''
        }
        oInput.onkeyup = function(){
          var url = 'https://sp0.baidu.com/5a1Fazu8AA54nxGko9WTAnF6hhy/su?wd='+this.value+'&cb=searchResult';
          var oS = document.createElement('script');
          oS.src = url;
          document.head.appendChild(oS);
        };
      };
    </script>
    </html>
    

      

  • 相关阅读:
    mysql分表那些事
    java根据经纬度计算距离
    java Calendar类的使用
    mysql中DATETIME、DATE和TIMESTAMP的区别
    java设计模式
    dubbo教程
    Java算法
    随机产生字符串
    js根据类名获取元素的底层原理
    元素样式的获取
  • 原文地址:https://www.cnblogs.com/TTTK/p/6306296.html
Copyright © 2011-2022 走看看