如何給自己的網站添加站內搜索?


不管是個人站還是企業站,不管是對於是么行業的網站,有一個站內搜索會很大化的提升用戶體驗的效果。但是很多剛剛摸索互聯網的新站長都不熟悉如何操作,因此我推薦大家使用搜索引擎來代替站內搜索。使用搜索引擎來進行站內搜索往往比自己編寫的站內搜索更高效,並且不占用網站服務器的資源,下面是我搜集到的幾個主要搜索引擎(Google和百度、雅虎)的站內搜索代碼,使用時只需要將代碼里的www.workpermit.com.cn替換成你的網址即可。

首先說一下國內使用最多的搜索引擎---百度搜索引擎的站內搜索代碼!

<!--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.workpermit.com.cn">
</form>
<!--Baidu站內搜索結束-->

 

<!--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.workpermit.com.cn">
<input type=hidden name=sitesearch value="www.workpermit.com.cn">
</form>
<!--Google站內搜索結束-->

<!--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.workpermit.com.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.workpermit.com.cn&sitesearch=www.workpermit.com.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.williamlong.info&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站內搜索結束-->


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM