怎么給網站添加Google和百度、雅虎的站內搜索代碼
怎么給網站添加Google和百度、雅虎的站內搜索代碼?
Google和百度、雅虎的站內搜索可以使訪問者快速的找到想要瀏覽的內容,而使用搜索引擎來進行站內搜索往往比自己編寫的站內搜索更高效,并且不占用網站服務器的資源。
下面是主流搜索引擎Google、百度和雅虎的站內搜索代碼,使用時只需要將代碼里的"www.h4pj6t.cn"替換成你的網址即可。缺點是沒有收錄的文章將不會被搜索到。
將以下代碼插入網頁<body>--代碼--</body>之間即可
<!–Google站內搜索開始–>
<form method=get action="http://www.google.com/search">
<input type=text name=q>
<input type=submit name=btnG value="Google 搜索">
<input type=hidden name=ie value=GB2312>
<input type=hidden name=oe value=GB2312>
<input type=hidden name=hl value=zh-CN>
<input type=hidden name=domains value="www.h4pj6t.cn">
<input type=hidden name=sitesearch value="www.h4pj6t.cn">
</form>
<!–Google 站內搜索結束–>
<!–百度Baidu站內搜索開始–>
<form action="http://www.baidu.com/baidu">
<input type=text name=word>
<input type="submit" value="Baidu 搜索">
<input name=tn type=hidden value="bds">
<input name=cl type=hidden value="3">
<input name=ct type=hidden value="2097152">
<input name=si type=hidden value="www.h4pj6t.cn">
</form>
<!–Baidu 站內搜索結束–>
<!–雅虎Yahoo站內搜索開始–>
<form action="http://www.yahoo.com.cn/search">
<input type=text name="p">
<input type="submit" value="Yahoo 搜索">
<input type=hidden name=vs value="www.h4pj6t.cn">
</form>
<!–Yahoo 站內搜索結束–>
以下是Google和百度的Javascript版的站內搜索代碼:
<!–Google站內搜索開始–>
<script type="text/javascript">
function googlesearch () {
var wq=document.getElementsByName("wq")[0].value;
var link="http://www.google.com/search?domains=www.h4pj6t.cn&sitesearch=www.h4pj6t.cn&q="+wq;
window.open(link); }
</script>
<input type="text" name="wq"/><input type="submit" onclick="javascript:googlesearch()" value="Google 搜索" />
<!–Google站內搜索結束–>
<!–Baidu站內搜索開始–>
<script language="javascript">
function baidusearch () {
var wd=document.getElementsByName("wd")[0].value;
var link="http://www.baidu.com/s?si=www.h4pj6t.cn&cl=3&ct=2097152&tn=baidulocal&word="+wd;
window.open(link); }
</script>
<input type="text" name="wd"/><input type="submit" onclick="javascript:baidusearch()" value="Baidu 搜索" />
<!–Baidu 站內搜索結束–>