日期:2014-05-16  浏览次数:20350 次

JavaScript集成搜索

  尘封在信箱里很久的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,