`

用js 给自己的网站做搜索框

阅读更多
 
<html>
<head>
<script language="javascript" >
function baidu()
{
  var startDate, endDate ,d ;
  d = new Date();
  startDate =d.getYear() + "-"+ (d.getMonth() + 1) + "-" + d.getDate() ;      //开始日期
  endDate =d.getYear() + "-"+ d.getMonth()  + "-" + d.getDate();         // 结束日期
window.open("http://www.baidu.com/s?tn=tcha_pg&word="+startDate+"endDate="+endDate+"");
}
function google()
{
window.open("http://www.google.cn/search?hl=zh-CN&q="+document.myform.mytext.value+"
&btnG=Google+%E6%90%9C%E7%B4%A2&meta=&aq=-1&oq=");  
}
function KeyDown(event)  //回车提交数据  ( 这样火符也可以用 )
{
event = event ? event : (window.event ? window.event : null);
if (event.keyCode == 13)
{
event.returnValue=false;
event.cancel = true;
google();
}
}
</script>
</head>
<body>
<center>
<form name="myform">

<input type="text" value="请输入搜索内容" name="mytext" maxlength="2048" size="55"

onkeydown="KeyDown(event)" onMouseOver="this.select();"/>

<input type="button"  value="google"  onclick="google()" /> 
<input type="button" value="最新报告" onclick="baidu()" />
</form>
</center>
</body>
</html> 
<style type="text/css">.csharpcode, .csharpcode pre { font-size: small; color: black; font-family: consolas, "Courier New", courier, monospace; background-color: #ffffff; /*white-space: pre;*/ } .csharpcode pre { margin: 0em; } .csharpcode .rem { color: #008000; } .csharpcode .kwrd { color: #0000ff; } .csharpcode .str { color: #006080; } .csharpcode .op { color: #0000c0; } .csharpcode .preproc { color: #cc6633; } .csharpcode .asp { background-color: #ffff00; } .csharpcode .html { color: #800000; } .csharpcode .attr { color: #ff0000; } .csharpcode .alt { background-color: #f4f4f4; width: 100%; margin: 0em; } .csharpcode .lnum { color: #606060; } </style> <style type="text/css">.csharpcode, .csharpcode pre { font-size: small; color: black; font-family: consolas, "Courier New", courier, monospace; background-color: #ffffff; /*white-space: pre;*/ } .csharpcode pre { margin: 0em; } .csharpcode .rem { color: #008000; } .csharpcode .kwrd { color: #0000ff; } .csharpcode .str { color: #006080; } .csharpcode .op { color: #0000c0; } .csharpcode .preproc { color: #cc6633; } .csharpcode .asp { background-color: #ffff00; } .csharpcode .html { color: #800000; } .csharpcode .attr { color: #ff0000; } .csharpcode .alt { background-color: #f4f4f4; width: 100%; margin: 0em; } .csharpcode .lnum { color: #606060; } </style>
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics