<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<style>
* {
padding: 0;
margin: 0
} .sousuo {
width: 300px;
height: 40px;
position: absolute;
margin: auto;
top: 0;
left: 0;
bottom: 0;
right: 0;
} li {
list-style: none;
line-height: 30px;
padding: 0 10px;
} li:hover {
background-color: #777;
color: #fff;
} ul {
position: absolute;
display: none;
}
</style>
</head>
<body>
<input type="text" class="sousuo"/>
<ul class="ul"></ul>
<script src="../blog/javascripts/jquery-1.7.2.min.js"></script>
<script> function position() {
var sousuo = $(".sousuo");
$(".ul").css({
top: sousuo.offset().top + sousuo.height() + 5,
left: sousuo.offset().left,
width: sousuo.css("width")
})
}
function demo(data) {
var ul = $('.ul');
var html = '';
if (data.s.length) {
ul.css("display",'block');
for (var i = 0; i<data.s.length; i++) {
html +='<li>'+data.s[i]+'</li>';
}
ul.html(html);
}
}
$(".ul").delegate("li",'click',function () {
location.href = 'https://www.baidu.com/s?wd='+$(this).text();
});
$(document).ready(function () {
position();
$('.sousuo').on('keyup', function () {
if (this.value) {
var script = document.createElement("script");
script.src = 'https://sp0.baidu.com/5a1Fazu8AA54nxGko9WTAnF6hhy/su?wd='+this.value+'&cb=demo';
document.body.appendChild(script);
}
});
});
window.onresize = function () {
position();
}
</script>
</body>
</html>

百度跨域搜索demo的更多相关文章

  1. H5新增的postMessage跨域解决方案Demo

    Demo背景:html中使用iframe嵌入了跨域的vue项目,在html中将参数传入到跨越的vue项目中. 向跨越的子窗口中发送数据 function sendMessage(data) { // ...

  2. Api之Cors跨域以及其他跨域方式

    Web Api之Cors跨域以及其他跨域方式(三)   我们知道ajax不能跨域访问,但是有时我们确实需要跨域访问获取数据,所以JSONP就此诞生了,其本质使用的是Script标签,除JSONP以外还 ...

  3. Web Api之Cors跨域以及其他跨域方式(三)

    我们知道ajax不能跨域访问,但是有时我们确实需要跨域访问获取数据,所以JSONP就此诞生了,其本质使用的是Script标签,除JSONP以外还有另外实现跨域方式 一.手动实现JSONP跨域 1.首先 ...

  4. Angular通过CORS实现跨域方案

    以前有一篇很老的文章网上转了很多,包括现在如果你百度"跨域"这个关键字,前几个推荐的都是"Javascript跨域总结与解决方案".看了一下感觉手段有点陈旧了, ...

  5. 简单JSONP跨域请求

    JSONP原理:利用<script>标签的src属性实现跨域的请求.可在URL中提供回调函数的名字.后台进过处理后将数据以回调函数参数的形式返回. demo:JSONP请求不同端口的数据 ...

  6. jsonp跨域实现

    原理:借助script可以跨域的思想,将跨域请求放在script中,当页面解析到改script标签时,就会向该src指向的地址发出一个请求,达到跨域请求的目的. 两点:(1)主要是利用了 <sc ...

  7. Vue使用vue-recoure + http-proxy-middleware + vuex配合promise实现基本的跨域请求封装

    使用vue init webpack 你的项目名称初始化一个vue的项目 安装依赖 npm install vue-resource http-proxy-middleware vuex koa 在项 ...

  8. node端代理浏览器路由 解决浏览器跨域问题

    var _ = require('lodash'); var request = require("request"); /* @LM 2017-02-16 node端代理浏览器路 ...

  9. JSONP实现Ajax跨域请求

    前言 由于浏览器存在同源策略的机制,所谓同源策略就是阻止从一个源(域名,包括同一个根域名下的不同二级域名)加载的文档或者脚本获取/或者设置另一个源加载的文档属性. 但比较特别的是:由于同源策略是浏览器 ...

随机推荐

  1. leetcode-两个数组交集(包含重复元素)

    Python解法代码: class Solution: def intersect(self, nums1: List[int], nums2: List[int]) -> List[int]: ...

  2. 一次Spring Transactional嵌套事务使用不同的rollbackFor的分析

    起因: 项目期间由于一次异常回滚问题,发现自己在事务知识方面知识的遗漏,趁着这次机会,做了几次rollbackFor的测试. 测试:   现在有两个事务,事务oute包含事务Inner.事务A回滚规则 ...

  3. (转)The connection to adb is down, and a severe error has occured. .

    转:http://blog.csdn.net/yu413854285/article/details/7559333 启动android模拟器时.有时会报The connection to adb i ...

  4. HDU6447 YJJ's Salesman-2018CCPC网络赛-线段树求区间最值+离散化+dp

    目录 Catalog Solution: (有任何问题欢迎留言或私聊 && 欢迎交流讨论哦 Catalog Problem:Portal传送门  原题目描述在最下面.  1e5个点,问 ...

  5. easyUI tabs 显示与隐藏 tab 页

    隐藏: tab_option = $('#tabs').tabs('getTab'," 单位信息 ").panel('options').tab; tab_option.hide( ...

  6. Centos7.5安装kafka集群

    Tags: kafka Centos7.5安装kafka集群 Centos7.5安装kafka集群 主机环境 软件环境 主机规划 主机安装前准备 安装jdk1.8 安装zookeeper 安装kafk ...

  7. 剑指offer——04从尾到头打印链表

    题目描述 输入一个链表,按链表从尾到头的顺序返回一个ArrayList.   有多种方法. class Solution { public: vector<int> printListFr ...

  8. tensorflow run()和 eval()

    eval()只能用于tf.Tensor类对象,也就是有输出的Operation.对于没有输出的Operation, 可以用.run()或者Session.run() 所以我们训练的时候,对于优化器只能 ...

  9. varnish(转http://www.ttlsa.com/nginx/varnish-4-configure-file/)

    2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 ...

  10. Myeclipse配置tomcat和jdk

    1.打开Myeclipse,Windows--preference--出现如下窗口.Browse为导入解压的tomcat路径. 2.配置jdk.使用哪个tomcat,就配置哪个tomcat下的jdk, ...