您的位置:首页 > 运维架构 > 网站架构

用google的搜索功能对相关网站进行搜索,并对搜索框进行相应的设置

2011-02-09 14:10 609 查看
javascript代码:

function checkinput() {
var googleinput=document.getElementById("googleinput");
if (googleinput.value.length<=0 || googleinput.value=="请输入你想查询的内容") {
alert("请输入你想查找的内容");
googleinput.focus();
return false;
}
else{
setTimeout("clearit()",1000);  //1秒之后对文本框中的内容进行清空
return true;
}
}

function clearit(){
var googleinput=document.getElementById("googleinput");
googleinput.value="";

}

function inputfocus(){
var googleinput=document.getElementById("googleinput");
googleinput.style.color="#000";
if(googleinput.value=="请输入你想查询的内容"){
googleinput.value="";
}
}
function inputblur(){
var googleinput=document.getElementById("googleinput");
if(googleinput.value.length<=0){
googleinput.value="请输入你想查询的内容";
googleinput.style.color="#999";
}
}


网页内容:

<form name="google" action="http://www.google.com.hk/search" method="get" onsubmit="return checkinput();">
<input type="hidden" value="zh-CN" name="hl" />
<input type="hidden" value="zh-CN" name="inlang" />
<input type="hidden" value="GB2312" name="ie" />
<input type="hidden" value="GB2312" name="oe" />
<input type="hidden" value="www.anchao.org.cn" name="domains" />
<input type="hidden" value="www.anchao.org.cn" name="sitesearch" />
<input type="text" id="googleinput" name="q" onfocus="inputfocus()" onblur="inputblur()" style="color:#999;" mce_style="color:#999;" value="请输入你想查询的内容" autocomplete="off" class="search" />
<input name="cx" type="submit" value="查询" />
</form>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: