一款DIY百度搜索框代码,解决百度站内搜索不支持HTTPS问题

来自:Jane博客
时间:2019-06-12
阅读:

有时候真不知道百度怎么想的,在大力宣扬网站支持https是时代发展的趋势时,却连自家产品都还停留在http阶段,例如百度分享,例如百度站内搜索。或许百度根本就不重视上述两个产品?真不知它葫芦里卖的什么药。

但是抱怨归抱怨,百度的产品该用还得用。在网上看到许多站长希望将百度站内搜索放在自己网页上,但除了有很少站长给出解决办法之外,基本上都是抱怨不支持https为多。看了网上的教程,要么解决方案比较复杂,要么根本用不上(不知方法失效还是咋的)。

下面,Jane将为大家分享一个百度搜索框代码,希望对大家有帮助。

优点:可以很好的兼容于https网站。

缺点:不是原生百度站内搜索代码,仅满足站内搜索需求,不支持搜索结果页设置。

一款DIY百度搜索框代码,解决百度站内搜索不支持HTTPS问题

效果图

部署代码时请将域名freexyz.cn改为自己网站一级域名(通常不带www的域名收录数量较多,搜索结果也相对较多一点)

搜索代码

<div class="wp" id="diy_search">
<form name="f1" action="http://www.bAIdu.com/baidu" target="_blank">
<div width="450px">
            <div height="40">
            <span width="370">
            <input name="word" maxlength="80" style="width:360px;" class="search_txt" />
            <input name=tn type=hidden value="0051" />
            <input name=cl type=hidden value="3" />
            <input name=ct type=hidden value="2097152" />
            <input name=si type=hidden value="freexyz.cn" />
            </span>
            <span width="80">
            <input type="submit" value="百度一下" class="search_submit" />
            </span>
            </div>
</div>
    </form>
</div>

CSS样式

#diy_search{
     margin-top:1px;
     margin-left:250px;
     padding:2px;
     width:600px;
 }
#diy_search .search_txt{
    background-color: #ffffff;
    border-style: solid;
    border-width: 1px;
    border-color: #338bf9;
    height: 35px;
    width:400px;
    float:left;
    padding-left:10px;
}
#diy_search .search_submit{
    background-color: #338bf9;
    border-style: solid;
    border-width: 1px;
    border-color: #338bf9;
    color: #ffffff;
    height:35px;
    width: 80px;
}
返回顶部
顶部