跨域解决请求限制(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 = ''}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>
轉載于:https://www.cnblogs.com/TTTK/p/6306296.html
總結
以上是生活随笔為你收集整理的跨域解决请求限制(script标签)(热门搜索出现对应的词条)的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Ubuntu14-04安装redis和p
- 下一篇: linux中重定向学习总结