2019独角兽企业重金招聘Python工程师标准>>>

看到一些网站上添加了各种搜索引擎。如Google、百度、360、有道等,就有点好奇,这个怎么实现?研究了一各个搜索引擎怎么传送关键字,找到了小窍门,于是乎,自家弄了一个百家搜索:

效果:

演示地址戳此:http://sousuodaquan.sinaapp.com/

ps:在列表中添加了糯米汇(http://www.nuomihui.com)的站内搜索,仅用于演示,别无它用,特此声明。

HTML代码:

<div class="sdiv"><form id="sform" method="get" target="_blank" action="http://www.baidu.com/s"><div class="mains"><ul id="selectul"><li id="selectedli" style="background-color: white;">百度</li><li>百度</li><li>谷歌</li><li>必应</li><li>有道</li><li>搜搜</li><li>搜狗</li><li>360</li><li>爱淘宝</li><li>亚马逊</li><li>当当</li><li>知道</li><li>维基</li><li>Crea</li><li class="lastli">糯米汇</li></ul><input type="text" name="wd" id="findParam"/></div><input type="submit" value="搜索" id="btn" /></form><h4 style="margin-left:100px">出处:<a href="http://www.ido321.com/" target="_blank">淡忘~浅思</a></h4></div>

JavaScript:

window.onload = function(){            var selectul = document.getElementById('selectul');            var lis = selectul.getElementsByTagName('li');            var selectedli = document.getElementById('selectedli');            var findParam = document.getElementById('findParam');            var sform = document.getElementById("sform");            var lislen = lis.length;            for (var i = 0; i < lislen; i++) {lis[i].onmouseover=function(){selectul.style.overflow = "visible";};lis[i].onmouseout=function(){selectul.style.overflow = "hidden";};lis[i].onclick = function(){selectedli.innerHTML = this.innerHTML;                    switch(this.innerHTML){                        case "百度":findParam.name='wd';sform.action = "http://www.baidu.com/s";                             break;                        case "谷歌":findParam.name='q';sform.action = "http://www.google.com.hk/search";                             break;                        case "必应":findParam.name='q';sform.action = "http://cn.bing.com/search";                             break;                        case "有道":findParam.name='query';sform.action = "http://www.sogou.com/web";                             break;                        case "搜搜":findParam.name='w';sform.action = "http://www.soso.com/q";                             break;                        case "搜狗":findParam.name='q';sform.action = "http://www.youdao.com/search";                             break;                        case "360":findParam.name='q';sform.action = "http://www.youdao.com/search";                             break;                        case "爱淘宝":findParam.name='key';sform.action = "http://ai.taobao.com/search/index.htm";                             break;                         case "亚马逊":findParam.name='field-keywords';sform.action = "http://www.amazon.cn/s/ref=nb_sb_noss";                             break;                         case "当当":findParam.name='key';sform.action = "http://search.dangdang.com/";                             break;                         case "知道":findParam.name='word';sform.action = "http://zhidao.baidu.com/search";                             break;                         case "维基":findParam.name='search';sform.action = "ttp://zh.wikipedia.org/w/index.php";                             break;                         case "Crea":findParam.name='q';sform.action = "http://search.creativecommons.org/";                             break;                         case "糯米汇":findParam.name='s';sform.action = "http://www.nuomihui.com/";                             break;}selectul.style.overflow = "hidden";};    };};

原文首发: http://www.ido321.com/1143.html

转载于:https://my.oschina.net/461147874/blog/356302

百家搜索:在网站中添加Google、百度等搜索引擎相关推荐

  1. wordpress谷歌字体_如何在WordPress中添加Google Maps

    wordpress谷歌字体 You can add all kind of content into your WordPress site. At WPBeginner we have shown ...

  2. 如何在WordPress中添加Google Maps Store Locator

    Do you want to add Google Maps store locator in WordPress? A store locator is a map pointing to your ...

  3. wordpress谷歌字体_如何以“正确”的方式在WordPress主题中添加Google Web字体

    wordpress谷歌字体 Google fonts are amazing free resource for web designers. In WPBv4, we have started us ...

  4. 【转】在你的博客中添加Google地图(Use Google Map API On Your Bolg)

    在你的博客中添加Google地图(Use Google Map API On Your Bolg) *+申请一组 Google Maps API Key 在使用 Google Maps API 之前, ...

  5. 一步一步SharePoint 2007之五:向网站中添加一个子网站

    一步一步SharePoint 2007之五:向网站中添加一个子网站 摘要 感受完看到成果的激动,感受完邻家女孩的漂亮.可爱和端庄,不要停止,来,让我们一起来动手打造心目中的完美女神吧! 本篇文章将介绍 ...

  6. 如何在网站中添加音乐

    来源:http://www.ido321.com/1042.html 发现有很多的个人博客中添加了背景音乐,以增强用户体验.LZ搜集到了两种在网站中添加音乐的方式. 一.豆瓣的FM         这 ...

  7. TogetherJS – 酷!在网站中添加在线实时协作功能

    TogetherJS是一个免费.开源的 JavaScript 库,来自 Mozilla 实验室,可以实现基于 Web 的在线协作功能.把 TogetherJS 添加到您的网站中,您的用户可以在实时的互 ...

  8. 如何在网站中添加验证码验证

    要在网站中添加验证码验证,可以按照以下步骤进行操作: 在HTML表单中添加验证码输入框.在表单中添加一个输入框,用于让用户输入验证码. 生成随机验证码并保存到会话中.在服务器端生成一个随机的验证码,并 ...

  9. 百度商桥放在php网站哪里_如何在网站中添加百度商桥?

    大部分新手站长都不知道竹子建站可以添加第三方的在线客服,商桥等功能.看到别人的网站设置的在线客服可以主动发消息,可以实时在线沟通,羡慕不能再羡慕了,告诉你不用羡慕,今天就教大家如何在网站中添加在线沟通 ...

最新文章

  1. Caused by: java.lang.NoClassDefFoundError: redis/clients/util/Pool
  2. Windows又发现安全漏洞 能够控制网络用户
  3. 极光推送android 区分开发测试,给自己的项目做极光推送的步骤
  4. .hpp文件_文件上传漏洞另类绕过技巧及挖掘案例全汇总
  5. python3 collections数据类型模块
  6. 2457: 很简单的一道题
  7. PS2: 这篇文章中的图片绘图工具使用的是Dia (sudo apt-get install dia)。据说yEd也很不错。...
  8. 2021牛客暑期多校训练营9,签到题HE
  9. 无刷新上传图片 可以实时预览 选择图片后即自动上传,没有上传按钮
  10. python 24点题目分析_24点游戏的递归解法和Python实现
  11. 刷脸支付会逐步取代扫码成为主流支付方式
  12. 免费积分文档下载神器
  13. 常见门电路逻辑符号对照(三态门,同或门,异或门,或非门,与或非门, 传输门,全加器,半加器,基本rs触发器,同步rs触发器,jk触发器,d触发器)
  14. 几个比较实用的网址链接
  15. html 怎么写出实心园,教您如何使用css3实现实心圆
  16. ABAP 透明表操作备忘 刘欣
  17. Mand Mobile - 滴滴出品的适用于金融项目的 Vue 移动端 UI 组件库,免费开源、灵活快速、丰富实用
  18. 第三十九期:1024特别版:向“程序媛们”致敬!
  19. 【历史上的今天】7 月 12 日:世界上第一台商用数字计算机;Python 之父卸任 BDFL;Wacom 成立
  20. PHP手表,基于PHP的手表购物商城网站的设计与实现(MySQL)(含录像)

热门文章

  1. 交叉编译Python-2.7.13到ARM(aarch32)平台
  2. 转载:bug的处理流程
  3. 世界公认的第一商人——成就犹太商人的15个信条
  4. 诗与远方:无题(十五)
  5. 诗与远方:无题(一)
  6. Mysql如何新建一个服务和移除所新建的服务
  7. URL中使用IPv4,IPv6和主机名
  8. java+connect+time+out_聊聊jdk httpclient的connect timeout异常
  9. Windows常用快捷键整理
  10. Prometheus-使用Prometheus监控Kubernetes集群