日期:2014-05-16 浏览次数:20359 次
<html> <head> <title>ReadRSS</title> <script src="common/prototype.js"></script> <script> function send_Request(url) { var request_url =url;//跨域的话,需要写一个代理. var request_pars = null; var myAjax = new Ajax.Request( request_url, { method:'get', parameters:request_pars, asynchronous:true, //true---异步;false---同步.默认为true onComplete:processRequest } ); } function processRequest(XML_Http_Request){ var results = XML_Http_Request.responseXML; var title = null; var item = null; var link = null; var ccc = results.getElementsByTagName("channel"); var headtitle = ccc[0].getElementsByTagName("title")[0].firstChild.nodeValue; var headlink = ccc[0].getElementsByTagName("link")[0].firstChild.nodeValue; var cell = document.createElement("div"); cell.innerHTML = "<h1><a href="+headlink+" target=_blank>"+headtitle+"</a></h1><br>"; $("result").appendChild(cell); var items = results.getElementsByTagName("item"); for(var i = 0; i < items.length; i++) { item = items[i]; link=item.getElementsByTagName("link")[0].firstChild.nodeValue; title = item.getElementsByTagName("title")[0].firstChild.nodeValue; var cell = document.createElement("div"); cell.innerHTML = "<li><a href="+link+" target=_blank>"+title+"</a></li><br>"; $("result").appendChild(cell); } } var myGlobalHandlers = { onCreate:function (){ Element.show('systemWorking'); }, onComplete:function (){ if(Ajax.activeRequestCount == 0){ Element.hide('systemWorking'); } } }; Ajax.Responders.register(myGlobalHandlers); </script> </head> <body onLoad="javascript:send_Request('http://esoft.bokee.com/rss2.xml');"> <div id='systemWorking'>Loading...</div> <div id="result"></div> </body> </html>