所属类别:开发技术
文章作者:mgod
特别推荐:免费发布信息 承包关键词~~抢爆了!HOT!
版权声明:原创作品,如需转载,请与作者联系。否则将追究法律责任。前几天突然想起来http://baigoogledu.com这个网站,那时候还是我在北京的时候那个市场的苏鑫磊告诉我的这个无敌的网站,就是将两个搜索集成到一起好让搜索的内容直观的做对比,闲来无事也来实现一个。看了看这个网站是使用的ASP,我就拿JAVASCRIPT来实现一下。麻烦的是Google还需要UrlEncode编码,否则显示中文还有问题。今天解决了,发上来代码给大家共享一下。有机会就架到空间上。<!DOCTYPEhtmlPUBLIC"-//W3C//DTDXHTML1.0Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">搜Google狗//使用vbscript来进行解码或加密Functionstr2asc(strstr)str2asc=hex(asc(strstr))EndFunctionFunctionasc2str(ascasc)asc2str=chr(ascasc)EndFunction/**//*这里开始时UrlEncode和UrlDecode函数*/functionUrlDecode(str){//解码varret="";for(vari=0;i0x7f){ret+=asc2str(parseInt("0x"+asc+str.substring(i+4,i+6)));i+=5;}else{ret+=asc2str(parseInt("0x"+asc));i+=2;}}else{ret+=chr;}}returnret;}functionUrlEncode(str){//加密varret="";varstrSpecial="!\"#$%&'()*+,/:;<=>?[]^`{}~%";for(vari=0;i0x7f){ret+="%"+c.slice(0,2)+"%"+c.slice(-2);}else{if(chr=="")ret+="+";elseif(strSpecial.indexOf(chr)!=-1)ret+="%"+c.toString(16);elseret+=chr;}}returnret;}functionchange(){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;}functionleftNone(){document.getElementById("leftDiv").style.display="none";document.getElementById("rightDiv").style.display="block";}functionrightNone(){document.getElementById("leftDiv").style.display="block";document.getElementById("rightDiv").style.display="none";}functionshowAll(){document.getElementById("leftDiv").style.display="block";document.getElementById("rightDiv").style.display="block";}functionkeyD(){if(event.keyCode==13){this.change();}} 10203050100条"/>版权所有 翻版不追究Mgod工作室本文出自 “赤色火焰.Net_学习手札” 博客,转载请与作者联系!本文出自 51CTO.COM技术博客
相关信息· JavaQ&A:使用Singleton模式?给我一个理由先!
· iframe自适应高度的多种方法方法小结
· Oracle数据库业务优化方法
· QQ游戏流行“火拼”
17130
15072
