<script type="text/javascript"> var XmlHttp; function ShowRSS() // 显示Rss内容 ... { var target=document.getElementById("Url"); ReadRSS(target.value); } function ReadRSS(Url) // Rss内容读取四步曲 ... { XmlHttp=getXMLRequest();//创建XmlHttp XmlHttp.onreadystatechange=HanderStateChange;//监听 XmlHttp.Open("Get",Url,true);//提交 XmlHttp.send(null);//传送参数 } function getXMLRequest( ) // 创建XmlHttp对象 ... { var xmlhttp_request = false; try...{ if( window.ActiveXObject ) //如果是IE浏览器 ...{ for( var i = 5; i; i-- ) ...{ try ...{ if( i == 2 ) ...{ xmlhttp_request = new ActiveXObject( "Microsoft.XMLHTTP" ); } else ...{ xmlhttp_request = new ActiveXObject( "Msxml2.XMLHTTP." + i + ".0" ); xmlhttp_request.setRequestHeader("Content-Type","text/xml"); xmlhttp_request.setRequestHeader("Content-Type","gb2312"); } break; }catch(e) ...{ xmlhttp_request = false; } } } else if( window.XMLHttpRequest )//如果是FilFox ...{ xmlhttp_request = new XMLHttpRequest(); if (xmlhttp_request.overrideMimeType) ...{ xmlhttp_request.overrideMimeType('text/xml'); } } }catch(e) ...{ xmlhttp_request = false; } return xmlhttp_request ; } // function CreateXMLDocument() { // var xRequest=null; // if (window.XMLHttpRequest) { // xRequest=new XMLHttpRequest(); // }else if (typeof ActiveXObject != "undefined"){ // xRequest=new ActiveXObject // ("Microsoft.XMLHTTP"); // } // return xRequest; // } function HanderStateChange() // 监视 如果回发已经结束则开始获取内容 ... { if (XmlHttp.readystate==4) ...{ if(XmlHttp.status==200) ...{ parseResults(); } } } function parseResults() // Rss的xml文本内容的读取 ... { var data=XmlHttp.responseXML; var str=""; var list=new Array(); list=data.getElementsByTagName("item"); for(var i=0; i<list.length; i++) ...{ var soure=list[i].childNodes; var title, link, dec; for(var j=0;j<soure.length;j++) ...{ if(soure[j].nodeName=="title") ...{ title=soure[j].nodeTypedValue; } else if(soure[j].nodeName=="link") ...{ link=soure[j].nodeTypedValue; } else if(soure[j].nodeName=="description") ...{ dec=soure[j].nodeTypedValue; } } str=str+"<a href='"+link+"'>"+title+"</a><br/>"; str=str+"<p>"+dec+"</p><br/>"; } document.getElementById('nameList').innerHTML =str; } </script>