前几天突然想起来http://baigoogledu.com这个网站,那时候还是我在北京的时候那个市场的苏鑫磊告诉我的这个无敌的网站,就是将两个搜索集成到一起好让搜索的内容直观的做对比,闲来无事也来实现一个。
看了看这个网站是使用的ASP,我就拿JAVASCRIPT来实现一下。麻烦的是Google还需要UrlEncode编码,否则显示中文还有问题。今天解决了,发上来代码给大家共享一下。有机会就架到空间上。

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>搜Google狗</title>
<script language="vbscript"> 
//使用vbscript来进行解码或加密
Function str2asc(strstr) 
str2asc 
= hex(asc(strstr)) 
End Function 
Function asc2str(ascasc) 
asc2str 
= chr(ascasc) 
End Function 
</script> 

<script language="javascript"> 
/*这里开始时UrlEncode和UrlDecode函数*/ 
function UrlDecode(str)
//解码
   var ret=""
   
for(var i=0;i<str.length;i++)
   
var chr = str.charAt(i); 
     
if(chr == "+")
       ret
+=" "
     }
else if(chr=="%")
     
var asc = str.substring(i+1,i+3); 
     
if(parseInt("0x"+asc)>0x7f)
       ret
+=asc2str(parseInt("0x"+asc+str.substring(i+4,i+6))); 
       i
+=5
     }
else
       ret
+=asc2str(parseInt("0x"+asc)); 
       i
+=2
     }
 
     }
else
       ret
+= chr; 
     }
 
   }
 
   
return ret; 
}
 


function UrlEncode(str)
//加密
   var ret=""
   
var strSpecial="!\"#$%&'()*+,/:;<=>?[]^`{|}~%"; 
   for(var i=0;i<str.length;i++){ 
   var chr = str.charAt(i); 
     var c=str2asc(chr); 
     if(parseInt("0x"+c) > 0x7f){ 
       ret+="%"+c.slice(0,2)+"%"+c.slice(-2); 
     }else{ 
       if(chr==" ") 
         ret+="+"; 
       else if(strSpecial.indexOf(chr)!=-1) 
         ret+="%"+c.toString(16); 
       else 
         ret+=chr; 
     } 
   } 
   return ret;


    function change()
    {
document.left.location.href="http://www.google.cn/search?num="+document.getElementById("showNum").value+"&complete=1&hl=zh-CN&newwindow=1&q="+UrlEncode

(document.getElementById("txtInput").value);
        
        document.right.location.href="http://www.sogou.com/web?query="+document.getElementById("txtInput").value+"&num="+document.getElementById

("showNum").value;
        
    }
    function leftNone()
    {
        document.getElementById("leftDiv").style.display="none";
        document.getElementById("rightDiv").style.display="block";
    }
    function rightNone()
    {
        document.getElementById("leftDiv").style.display="block";
        document.getElementById("rightDiv").style.display="none";
    }
    function showAll()
    {
        document.getElementById("leftDiv").style.display="block";
        document.getElementById("rightDiv").style.display="block";
    }
    function keyD()
    {
        
    
        if(event.keyCode==13)
        {            
            this.change();
        }
    
    }
    
    
</script>
</head>
<body>
<center>
  <img src="logo.jpg" align="middle" />
  <input name="txtInput" type="text" id="txtInput" onkeydown="keyD()"  />
  </label>
  <label>
  <input type="button" name="Submit" onclick="change()" value="点此搜索" />
  </label>
  <label> &nbsp;&nbsp;&nbsp;
  <select name="showNum" id="showNum">
    <option value="10" selected="selected">10</option>
    <option value="20">20</option>
    <option value="30">30</option>
    <option value="50">50</option>
    <option value="100">100</option>
  </select>
  </label>
  条
</center>
<table width="100%" height="100%" border="0">
  <tr>
    <td  height="100%" ><div id="leftDiv">
        <iframe src="#" scrolling="auto" name="left" width="100%" height="700px"></iframe>
      </div></td>
    <td width="14px"><div id="menu" style="float:left;">
        <input type="button" style="width:14px;height:30px;" name="button" id="button" onclick="leftNone()" value="<" />
        <br />
        <input type="button" style="width:14px;height:30px;" name="button2" id="button2" onclick="rightNone()" value=">" />
        <br />
        <input type="button" style="width:14px;height:30px;" name="button3" id="button3" onclick="showAll()" value="|" />
      </div></td>
    <td  height="100%"><div id="rightDiv">
        <iframe src="#" scrolling="auto" name="right"  width="100%"  height="700px" ></iframe>
      </div></td>
  </tr>
 </table>
         <center>
        版权所有&nbsp;&nbsp;翻版不追究<br />
        Mgod工作室
    </center> 
</body>
</html>