尘封在信箱里很久的JavaScript集成搜索的小例子。偶然翻了出来,重新整理了一下,在firefox和IE下测试居然通过。
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head> <!--<meta http-equiv="Content-Type" content="text/html; charset=utf-8">--> <title>集成搜索</title> <script type="text/javascript"> <!--// //选择所有对象 //function selectAll(obj){ // for (var i=0; i<obj.elements.length; i++) { // var elem = obj.elements[i]; // if (elem.name!="all") { // elem.checked = obj.all.checked; // } // } //} function search(checkboxName){ var mp31, mp32; var tom1, tom2; var sina1, sina2; var sohu1, sohu2; var baidu1, baidu2; var sbox1, sbox2; var flash1, flash2; var yahoo1, yahoo2; var google1, google2; var netEase1, netEase2; var text; var noEngin; var haveText; noEngin = true; haveText = true; text = checkboxName.text.value; if (text=="") { alert("请输入搜索内容!"); haveText = false; } mp31 = checkboxName.mp3.checked; mp32 = "http://mp3search.baidu.com/wstsearch?tn=baidump3&ct=134217728&word="+text; if (mp31){ noEngin = false; if (haveText){ newWin = window.open(mp32, "mp3","toolbar,location,directories,status,menubar,scrollbars,resizable=1"); } } tom1 = checkboxName.tom.checked; tom2 = "http://sms2.ctn.com.cn/smslist/smsearch.php?user_id=67&inc=3&keyword="+text; if (tom1){ noEngin = false; if (haveText){ newWin = window.open(tom2, "tom","toolbar,location,directories,status,menubar,scrollbars,resizable=1"); } } sina1 = checkboxName.sina.checked; sina2 = "http://search.sina.com.cn/cgi-bin/search/search.cgi?_searchkey="+text; if (sina1){ noEngin = false; if (haveText){ newWin = window.open(sina2, "sina","toolbar,location,directories,status,menubar,scrollbars,resizable=1"); } } sohu1 = checkboxName.sohu.checked; sohu2 = "http://site.search.sohu.com/sitesearch.jsp?key_word="+text; if (sohu1){ noEngin = false; if (haveText){ newWin = window.open(sohu2, "sohu","toolbar,location,directories,status,menubar,scrollbars,resizable=1"); } } baidu1 = checkboxName.baidu.checked; baidu2 = "http://www1.baidu.com/baidu?myselectvalue=0&tn=net900&word="+text; if (baidu1){ noEngin = false; if (haveText){ newWin = window.open(baidu2, "baidu","toolbar,location,directories,status,menubar,scrollbars,resizable=1"); } } sbox1 = checkboxName.sbox.checked; sbox2 = "http://union.3721.com/search_result.htm?oid=&e=&pid=S_cn76_2605&fw=union&argse=new3721&name="+text; if (sbox1){ noEngin = false; if (haveText){ newWin = window.open(sbox2, "sbox","toolbar,location,directories,status,menubar,scrollbars,resizable=1"); } } flash1 = checkboxName.flash.checked; flash2 = "http://flash.baidu.com/wstsearch?tn=flash&ct=33554432&word="+text; if (flash1){ noEngin = false; if (haveText){ newWin = window.open(flash2, "flash","toolbar,location,directories,status,menubar,scrollbars,resizable=1"); } } yahoo1 = checkboxName.yahoo.checked; yahoo2 = "http://cn.search.yahoo.com/search/cn?p="+text; if (yahoo1){ noEngin = false; if (haveText){ newWin = window.open(yahoo2, "yahoo","toolbar,location,directories,status,menubar,scrollbars,resizable=1"); } } google1 = checkboxName.google.checked; google2 = "http://google.cn76.com/search?hl=zh-CN&q="+text; if (google1){ noEngin = false; if (haveText){ newWin = window.open(google2, "google","toolbar,location,directories,status,menubar,scrollbars,resizable=1"); } } netEase1 = checkboxName.netEase.checked; netEase2 = "http://nisearch.163.com/Search?q="+text; if (netEase1){ noEngin = false; if (haveText){ newWin = window.open(netEase2, "netEase","toolbar,location,directories,status,menubar,scrollbars,resizable=1"); } } if (noEngin) { alert("请选择搜索引擎!"); } } //--> </script> </head> <body> <table style="width:760px; background-color: #FFFF00; layer-background-color: #CCCCCC; border: 1px none #000000"> <tr> <td> <font style="FONT-SIZE:9pt">集成搜索 </td> <td> <form name="engines" onSubmit="search(engines)"> <input style="background-color: fdf3d1; border: 1px solid #fbb723" name="text" size="10" maxlength="200" value=""> <input type="button" style="background-color:#ffffff;border-bottom:red 1px solid;border-left:red 1px solid;border-right:red 1px solid;border-top:red 1px solid;color:#000000;font-size:9pt" value="搜索" name="Submit" onClick="search(engines)"> <font style="font-size:9pt"> <input type="checkbox" name="baidu" checked="checked">百度 <input type="checkbox" name="google" checked="checked">Google <input type="checkbox" name="yahoo">雅虎 <input type="checkbox" name="sina">新浪 <input type="checkbox" name="sohu">搜狐 <input type="checkbox" name="netEase">网易 <input type="checkbox" name="sbox">网络实名 <input type="checkbox" name="tom">手机铃声 <input type="checkbox" name="flash">FLASH <input type="checkbox" name="mp3">MP3 </font> </td> </form> </tr> </table> </body> </html>
附件:集成搜索