////////////////////////// // cookies操作相关函数//// ////////////////////////// function setcookie(name,value)//两个参数,一个是cookie的名子,一个是值 { var Days = 30; //此 cookie 将被保存 30 天 var exp = new Date(); //new Date("December 31, 9998"); exp.setTime(exp.getTime() + Days*24*60*60*1000); document.cookie = name + "="+ escape (value) + ";expires=" + exp.toGMTString() + ";path=/;"; } function getcookie(name)//取cookies函数 { var arr = document.cookie.match(new RegExp("(^| )"+name+"=([^;]*)(;|$)")); if(arr != null) return unescape(arr[2]); return null; } function delcookie(name)//删除cookie { var exp = new Date(); exp.setTime(exp.getTime() - 1); var cval=getcookie(name); if(cval!=null) {setcookie(name,'');document.cookie= name + "="+cval+";expires="+exp.toGMTString()}; } var gb2utf8=function(data){ var glbEncode=[],t,i,j,len gb2utf8_data=data execScript("gb2utf8_data = MidB(gb2utf8_data, 1)+' '", "vbscript") t=escape(gb2utf8_data).replace(/%u/g,"").replace(/(.{2})(.{2})/g,"%$2%$1").replace(/%([A-Z].)%(.{2})/g,"@$1$2") t=t.split("@") i=0 len=t.length while(++i结果 var info = root.getElementsByTagName('item'); var infohtml=""; // 显示返回结果 //容错修复开始 var infocount=info.length //console.log("null"); for(var x=0;xparseFloat(info[x+1].childNodes.item(3).childNodes[0].data)) { //alert("冒泡"); temp=info[x+1].childNodes.item(0).childNodes[0].data; tempurl=info[x+1].childNodes.item(1).childNodes[0].data tempcount=info[x+1].childNodes.item(3).childNodes[0].data info[x+1].childNodes.item(0).childNodes[0].data=info[x].childNodes.item(0).childNodes[0].data; info[x+1].childNodes.item(1).childNodes[0].data=info[x].childNodes.item(1).childNodes[0].data; info[x+1].childNodes.item(3).childNodes[0].data=info[x].childNodes.item(3).childNodes[0].data; info[x].childNodes.item(0).childNodes[0].data=temp; info[x].childNodes.item(1).childNodes[0].data=tempurl; info[x].childNodes.item(3).childNodes[0].data=tempcount; } } } var rn_content=document.getElementById("relative1ul").innerHTML; if(infocount>=11){ for(var i=infocount-1;i>infocount-11;i--) { if(parseFloat(info[i].childNodes.item(3).childNodes[0].data)>3) {infohtml+='
  • '+info[i].childNodes.item(0).childNodes[0].data+'
  • ';licount++;} } } else { for(var i=infocount-1;i>0;i--) { if((parseFloat(info[i].childNodes.item(3).childNodes[0].data)>3)&&(rn_content.indexOf(info[i].childNodes.item(0).childNodes[0].data)==-1)) {infohtml+='
  • '+info[i].childNodes.item(0).childNodes[0].data+'
  • ';licount++;} } } document.getElementById("relative1ul").innerHTML=infohtml; if(licount<5) { document.getElementById("relative1ul").innerHTML+=rn_content.replace('暂无相关新闻',''); } if(document.getElementById("relative1ul").innerHTML.split("").length<6) { for(var i=infocount-1;((i>=0)&&(i>infocount-5));i--) { if((parseFloat(info[i].childNodes.item(3).childNodes[0].data)<3)&&(rn_content.indexOf(info[i].childNodes.item(0).childNodes[0].data)==-1)) { document.getElementById("relative1ul").innerHTML+='
  • '+info[i].childNodes.item(0).childNodes[0].data+'
  • ';} } } //正文内推荐开始 var zhengwen="",fenye="",fenyei=2; licount=0; if(infocount>=1){ for(var i=infocount-1;i>0;i--) { if((parseFloat(info[i].childNodes.item(3).childNodes[0].data)>=3)&&(licount<5)) { zhengwen+='   '+(parseFloat(info[i].childNodes.item(3).childNodes[0].data)>=10?'':'')+' '+forperword(info[i].childNodes.item(0).childNodes[0].data)+'
    '; if(parseFloat(info[i].childNodes.item(3).childNodes[0].data)>=10) { fenye+=''+fenyei+''; fenyei=fenyei+1; } licount++; } } if(fenye!=''){fenye="
    1"+fenye+" 总共"+(fenyei-1)+"篇相关内容
    "} if(document.getElementById("content")||document.getElementById("001ppbody")) { var checkTd_related=document.createElement("p"); if(document.getElementById("001ppbody")) {var otr_related=document.getElementById("001ppbody");} else {var otr_related=document.getElementById("content");} if(zhengwen!="") {checkTd_related.innerHTML="相信您对下列内容也会感兴趣:
    "+zhengwen; otr_related.appendChild(checkTd_related);} } } //正文内推荐结束 existflag="&exist=0"; //alert("存在xml并从中获得信息"); }else{//否则弹出错误信息 //alert(xmlhttp.status); document.getElementById("relative1ul").innerHTML=document.getElementById("relative1ul").innerHTML.replace('暂无相关新闻',''); if(xmlhttp.status==404); { existflag="&exist=1";//ajax 读取xml如果为500,下面relative.asp的action应为生成 //alert("不存在xml,应该要生成"); } } } document.getElementById("relative1ul").innerHTML=document.getElementById("relative1ul").innerHTML.replace('
  • ·
  • ',''); } //POST提交 xmlhttp.open("GET", url, true) xmlhttp.send(null); } function forperword(s){var td='';for(var i=0;i'+s.substr(i,1)+'');}return td;} if(document.getElementById("str_content")&&(typeof(newsid)!='undefined')) { var existflag="&exist=0"; var l_path=window.location.pathname; var l_id=newsid; var l_title=document.title; l_path=l_path.replace("_1.html",".html"); l_path=l_path.replace("_2.html",".html"); l_path=l_path.replace("_3.html",".html"); l_path=l_path.replace("_4.html",".html"); l_path=l_path.replace("_5.html",".html"); l_path=l_path.replace("_6.html",".html"); l_path=l_path.replace("_7.html",".html"); l_path=l_path.replace("_8.html",".html"); l_path=l_path.replace("_9.html",".html"); l_path=l_path.replace("_10.html",".html"); l_path=l_path.replace("_11.html",".html"); l_path=l_path.replace("_12.html",".html"); getbody(l_path.replace("html","xml")) }else {document.write('暂无相关数据');}