日期:2014-05-16 浏览次数:20454 次
<style>
.one{
width:100px;
height:20px;
border:1px solid #FF1001;
}
</style>
</head>
<body>
<script>
function searchit(){
document.getElementById('bd').onclick=function(e){var v=document.getElementById('search').value;window.open('http://www.baidu.com/s?wd='+v);}
}
</script>
<input name="textfield" type="text" id="search" />
<div onclick="searchit();" id="bd" class="one">百度搜索</div>
<script>
function searchit(n){
var v=document.getElementById('search').value;
if(v!=""){
var arr=["http://www.baidu.com/s?wd={kw}","https://www.google.com.hk/#newwindow=1&q={kw}&safe=strict"];
window.open(arr[n].replace(/{kw}/i,encodeURIComponent(v)));
}
}
</script>
<input name="textfield" type="text" id="search" />
<div onclick="searchit(0);" class="one">百度搜索</div>
<div onclick="searchit(1);" class="one">谷歌搜索</div>