zoukankan      html  css  js  c++  java
  • 如何给自己的网站添加站内搜索?

    不管是个人站还是企业站,不管是对于是么行业的网站,有一个站内搜索会很大化的提升用户体验的效果。但是很多刚刚摸索互联网的新站长都不熟悉如何操作,因此我推荐大家使用搜索引擎来代替站内搜索。使用搜索引擎来进行站内搜索往往比自己编写的站内搜索更高效,并且不占用网站服务器的资源,下面是我搜集到的几个主要搜索引擎(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站内搜索结束-->

  • 相关阅读:
    Eclipse常用快捷键
    Kali Linux安装Google中文输入法(只需5步)
    Kali Linux 更新源 操作完整版教程
    Oracle存储过程的异常处理
    Eclipse调试DEBUG时快速查看某个变量的值的快捷键、快速跳转到某行的快捷键
    oracle listagg和wm_concat函数
    ORACLE分页查询SQL语法——最高效的分页
    Mock拦截请求URL返回模板数据
    前端安全之XSS攻击及防御
    Sublime Text3注册码,亲测可用
  • 原文地址:https://www.cnblogs.com/jinnuohua/p/jinnuohua.html
Copyright © 2011-2022 走看看