谁能让这段JS有效啊!

jsjsrrr 2010-10-23 03:34:37
<div id="div_word_list">
<script>
var lastInput;var obj_div_word=document.getElementById("div_word_list");var selectedIndex=-1;function getData(source){var xmlHttp=false;if(window.XMLHttpRequest){xmlHttp=new XMLHttpRequest();}else if(window.ActiveXObject){xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");};if(xmlHttp){xmlHttp.open("GET",source);xmlHttp.onreadystatechange=function(){if(xmlHttp.readyState==4&&xmlHttp.status==200){var message=xmlHttp.responseText;var rData=eval("new Array("+message+");");if(rData.length>1){var callBack=Suggest_apply(frameElement,"Ajax",rData,new Array(""));eval(callBack);}else{document.getElementById("div_word_list").className="div_word_hidden";document.getElementById("div_word_list").innerHTML="";};selectedIndex=-1;}};xmlHttp.send(null);}};function connectSoSuggest(keyEvnet){var input=document.getElementById("wd");if(input.value){if(input.value){obj_div_word.style.display="";lastInput=escape(input.value);getData("key?wd="+escape(input.value));}}else{document.getElementById("div_word_list").className="div_word_hidden";document.getElementById("div_word_list").innerHTML="http://so.pps.tv/";}};function Suggest_apply(unusedVariable,searchWord,results,unusedArray){document.getElementById("div_word_list").className="div_word_show";var data="";for(var i=0;i<results.length;i+=2){data+="<div onmouseout=\"this.className=''\" onmouseover=\"this.className='div_word_selected'\"><span style=\"display:none;\">"+results[i]+"</span><a href=\"search?wd="+results[i]+"&cf=search\"><span>"+results[i+1]+"</span>"+results[i]+"</a></div>";};data+="<div ><span style=\"display:none;\"></span><a href=http://so.pps.tv/\"javascript:;\" onclick=\"document.getElementById('div_word_list').className = 'div_word_hidden';document.getElementById('div_word_list').innerHTML= '';\"><span>关闭</span>×</a></div>";document.getElementById("div_word_list").innerHTML=data;};function checkKeyCode(event){var keyCode=event.keyCode;if(keyCode==40||keyCode==38){var isUp=false;if(keyCode==40)isUp=true;chageSelection(isUp);}else if(keyCode==13){form1.submit();}else{connectSoSuggest(event);}};function chageSelection(isUp){var objouter=document.getElementById("div_word_list");var obj_wd=document.getElementById("wd");if(objouter.className=='div_word_hidden'){objouter.style.display='none';}else{objouter.className="div_word_show";if(isUp){selectedIndex=selectedIndex+1;}else{selectedIndex=selectedIndex-1;}};var maxIndex=objouter.childNodes.length-1;if(selectedIndex<0){selectedIndex=maxIndex};if(selectedIndex>maxIndex){selectedIndex=0};for(intTmp=0;intTmp<=maxIndex;intTmp++){if(intTmp==selectedIndex){objouter.childNodes[intTmp].className="div_word_selected";var nowDiv=objouter.childNodes[intTmp].innerHTM;if(nowDiv!='undefined')obj_wd.value=objouter.childNodes[intTmp].childNodes[0].innerHTML;}else{objouter.childNodes[intTmp].className="";}}}
var cid;cid=getCookies("pps_client_id");getStat(cid);function getCookies(a){var b=document.cookie.match(new RegExp("(^| )"+a+"=([^;]*)(;|$)"));if(b!=null)return unescape(b[2]);return''}function getStat(a){try{var b=new Image(1,1);var c=escape(document.referrer);var d=escape(location.href);b.src="http://stat.ppstream.com/write_so.php?wd=&last=&id="+a+"&cli=3&ref="+c+"&url="+d;b.onload=function(){return}}catch(e){}}function soStat(){try{var a=document.getElementById("wd").value;var b=getCookies("last_wd");var c=getCookies("pps_client_id");var d=new Image(1,1);var f=escape(document.referrer);var g=escape(location.href);d.src="http://stat.ppstream.com/write_so.php?id="+c+"&cli=3&ref="+f+"&url="+g+"&key="+a+"&last="+b;d.onload=function(){return}}catch(e){}}
document.onmouseup = function() { document.getElementById("div_word_list").style.display = "none";} </script>
...全文
147 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
Li_JT 2010-10-25
  • 打赏
  • 举报
回复
var lastInput;
var obj_div_word=document.getElementById("div_word_list");
var selectedIndex=-1;
function getData(source)
{
var xmlHttp=false;
if(window.XMLHttpRequest)
{
xmlHttp=new XMLHttpRequest();
}
else if(window.ActiveXObject)
{
xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
};
if(xmlHttp)
{
xmlHttp.open("GET",source);
xmlHttp.onreadystatechange=function()
{
if(xmlHttp.readyState==4&&xmlHttp.status==200)
{
var message=xmlHttp.responseText;
var rData=eval("new Array("+message+");");
if(rData.length>1)
{
var callBack=Suggest_apply(frameElement,"Ajax",rData,new Array(""));
eval(callBack);
}
else
{
document.getElementById("div_word_list").className="div_word_hidden";
document.getElementById("div_word_list").innerHTML="";
};
selectedIndex=-1;
}
};
xmlHttp.send(null);
}
};
function connectSoSuggest(keyEvnet)
{
var input=document.getElementById("wd");
if(input.value)
{
if(input.value)
{
obj_div_word.style.display="";
lastInput=escape(input.value);
getData("key?wd="+escape(input.value));
}
}
else
{
document.getElementById("div_word_list").className="div_word_hidden";
document.getElementById("div_word_list").innerHTML="http://so.pps.tv/";
}
};
function Suggest_apply(unusedVariable,searchWord,results,unusedArray)
{
document.getElementById("div_word_list").className="div_word_show";
var data="";
for(var i=0;i<results.length;i+=2)
{
data+="<div onmouseout=\"this.className=''\" onmouseover=\"this.className='div_word_selected'\"><span style=\"display:none;\">"+results[i]+"</span><a href=\"search?wd="+results[i]+"&cf=search\"><span>"+results[i+1]+"</span>"+results[i]+"</a></div>";
};
data+="<div ><span style=\"display:none;\"></span><a href=http://so.pps.tv/\"javascript:;\" onclick=\"document.getElementById('div_word_list').className = 'div_word_hidden';document.getElementById('div_word_list').innerHTML= '';\"><span>关闭</span>×</a></div>";
document.getElementById("div_word_list").innerHTML=data;
};
function checkKeyCode(event)
{
var keyCode=event.keyCode;
if(keyCode==40||keyCode==38)
{
var isUp=false;
if(keyCode==40)isUp=true;
chageSelection(isUp);
}
else if(keyCode==13)
{
form1.submit();
}
else
{
connectSoSuggest(event);
}
};
function chageSelection(isUp)
{
var objouter=document.getElementById("div_word_list");
var obj_wd=document.getElementById("wd");
if(objouter.className=='div_word_hidden')
{
objouter.style.display='none';
}
else
{
objouter.className="div_word_show";
if(isUp)
{
selectedIndex=selectedIndex+1;
}
else
{
selectedIndex=selectedIndex-1;
}
};
var maxIndex=objouter.childNodes.length-1;
if(selectedIndex<0)
{
selectedIndex=maxIndex
};
if(selectedIndex>maxIndex)
{
selectedIndex=0
};
for(intTmp=0;intTmp<=maxIndex;intTmp++)
{
if(intTmp==selectedIndex)
{
objouter.childNodes[intTmp].className="div_word_selected";
var nowDiv=objouter.childNodes[intTmp].innerHTM;
if(nowDiv!='undefined')obj_wd.value=objouter.childNodes[intTmp].childNodes[0].innerHTML;
}
else
{
objouter.childNodes[intTmp].className="";
}
}
}
var cid;
cid=getCookies("pps_client_id");
getStat(cid);
function getCookies(a)
{
var b=document.cookie.match(new RegExp("(^| )"+a+"=([^;]*)(;|$)"));
if(b!=null)return unescape(b[2]);
return''
}
function getStat(a)
{
try
{
var b=new Image(1,1);
var c=escape(document.referrer);
var d=escape(location.href);
b.src="http://stat.ppstream.com/write_so.php?wd=&last=&id="+a+"&cli=3&ref="+c+"&url="+d;
b.onload=function()
{
return
}
}
catch(e)
{
}
}
function soStat()
{
try
{
var a=document.getElementById("wd").value;
var b=getCookies("last_wd");
var c=getCookies("pps_client_id");
var d=new Image(1,1);
var f=escape(document.referrer);
var g=escape(location.href);
d.src="http://stat.ppstream.com/write_so.php?id="+c+"&cli=3&ref="+f+"&url="+g+"&key="+a+"&last="+b;
d.onload=function()
{
return
}
}
catch(e)
{
}
}
document.onmouseup = function()
{
document.getElementById("div_word_list").style.display = "none";
}



这个是格式化之后的代码,lz自己看看,我没仔细看。
yhtapmys 2010-10-24
  • 打赏
  • 举报
回复
先格式化下代码吧
fellowcheng 2010-10-23
  • 打赏
  • 举报
回复
lz拷贝的代码少了个</div> <script>也最好改为<script type="text/javascript">


这段代码又是ajax,可能还获取了什么cookies,只给这些东西没法子帮你分析呀
程序园苑 2010-10-23
  • 打赏
  • 举报
回复
楼上说得对,够乱的了
小辛、 2010-10-23
  • 打赏
  • 举报
回复

很好很强大!~~~~~~~~~` 乱的不能在乱了@!~~~~~~~~~~~~~~~~~~~~~~~~
真哥哥 2010-10-23
  • 打赏
  • 举报
回复

87,901

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧