function $(oo){ var oo=document.getElementById(oo)?document.getElementById(oo):''; return oo; } function runCode(code){ var _c=window.open("","",""); _c.opener=null; _c.document.write(code); _c.document.close(); } function createXMLHttpRequest(){ if(window.ActiveXObject){ xmlHttp = new ActiveXObject("Microsoft.XMLHTTP"); }else if(window.XMLHttpRequest) { xmlHttp = new XMLHttpRequest(); } } function startRequest(url,returnfun) { createXMLHttpRequest(); xmlHttp.onreadystatechange =returnfun; xmlHttp.open("GET",url,true); xmlHttp.send(null); } var tmptxt=''; function gositesearch(keyword){ oldkeyword=keyword; if (tmptxt=='') { tmptxt=$("indexhtml").innerHTML;// 保存临时变量 } ylmftime=new Date().getTime(); url='sou.asp?key='+escape(keyword)+'&ylmftime='+ylmftime; $("indexhtml").innerHTML='
'; startRequest(url,showsearchsite); } function showsearchsite(){ { if(xmlHttp.readyState == 4){ txt=xmlHttp.responseText; $("indexhtml").innerHTML=txt;}} } function showindexhtml(){ if(tmptxt!=''){ $("indexhtml").innerHTML=tmptxt; } } function JHshStrLen(sString) { var sStr,iCount,i,strTemp ; iCount = 0 ; sStr = sString.split(""); for (i = 0 ; i < sStr.length ; i ++) { strTemp = escape(sStr[i]); if (strTemp.indexOf("%u",0) == -1) // 表示是汉字 { iCount = iCount + 1 ; } else { iCount = iCount + 2 ; } } return iCount ; } var oldkeyword=''; function KeyDown() { if (event.keyCode == 13) { event.returnValue=false; event.cancel = true; if(JHshStrLen($('sitekeyword').value)<-5){ alert('请输入要搜索的关键字或关键字不能少于2个字节!!'); }else{ if ($('sitekeyword').value!=oldkeyword) { gositesearch($('sitekeyword').value); } } } } function input(){ if(JHshStrLen($('sitekeyword').value)<-1 ){//||JHshStrLen($('sitekeyword').value)<1 // showindexhtml(); }else{ // $("indexhtml").innerHTML=JHshStrLen($('sitekeyword').value); // 请求判断 // if (xmlHttp.readyState!=4) //{ // xmlHttp.abort(); //} if ($('sitekeyword').value!=oldkeyword) { gositesearch($('sitekeyword').value); } } }