为站点添加百度搜索框
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width = device-width",initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no">
<title>baidu</title>
<style type="text/css">
/*body,html{ height: 100%; width: 100%; }*/ *{ margin: 0px; padding: 0px; }
#img{ width: 2rem; margin: 100px auto 0px; } #img img{ width: 2rem; height: 1.2rem; }
#te{ height: 0.2rem; line-height: 0.2rem; width: 2.5rem; float: left; text-indent: 0.05rem; }
#but{ width: 0.4rem; height: 0.22rem; line-height: 0.2rem; float: left; }
#box{ width: 3.0rem; margin: 0 auto 0; position: relative; }
#show{ width: 3.0rem; /*border: 1px solid red;*/ margin:0 auto 0; display: none; position: relative; }
#show ul li{ float: left; width: 2rem; height: 0.2rem; list-style: none; } a{ text-decoration: none; display: block; font-size: 0.1rem; }
</style>
</head>
<body>
<div id="img">
<img src="images/logo.png">
</div>
<div id="box">
<input type="text" name="search" id="te">
<input type="button" name="" id="but" value="百度一下">
</div>
<div id="show"> <ul> </ul> </div>
<script type="text/javascript" >
document.getElementsByTagName('html')[0].style.fontSize = document.documentElement.clientWidth/10 + "px";
var inp = document.getElementById('te'); var show = document.getElementById('show');
var oul = document.getElementsByTagName('ul')[0];
inp.onkeyup = function(){ if(inp.value){ show.style.display="block"; }
else{ show.style.display="none"; }
var os = document.createElement('script');
os.src='https://sp0.baidu.com/5a1Fazu8AA54nxGko9WTAnF6hhy/su?wd='+inp.value+'&json=1&p=3&sid=1458_21079_18133_20697_20930&req=2&csor=1&cb=figting' document.body.appendChild(os); }