使用Bing站内搜索

in 网页代码 with 0 commentand 1042 read

因为自己的网站百度未收录╮(╯-╰)╭,本来之前用的谷歌,但是谷歌毕竟翻墙才能用。决定还是换微软的Bing搜索引擎来做站内搜索吧。

大概是这样的效果
使用Bing站内搜索


代码奉上

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>bing search</title>
</head>
<body>
    <h1>Bing Search</h1>
    <form action="https://bing.com/search" id="searchForm">
        <input type="text" name="q" value="" required>
        <input type="hidden" name="site" value="www.ioio.pw">
        <input type="submit" value="Search">
    </form>
<script>
    var searchForm = document.getElementById('searchForm');
    searchForm.onsubmit = function(){
        var url = this.action;
        var q = this.children['q'].value;
        var site = this.children['site'].value;
        var url = url + '?q='+q+' site:'+ site;
        window.open(url);
        return false;
    };
</script>
</body>
</html>

原文来自:https://www.ioio.pw/%E6%90%9C%E7%B4%A2%E5%BC%95%E6%93%8E/2018/09/15/bing-site-search.html

评论