»
EnglishFrenchVietnamese

Print - JavaScript RSS Reader - JavaScriptBank.com

Full version: jsB@nk » Utility » JavaScript RSS Reader
URL: http://www.javascriptbank.com/javascript-rss-reader.html

JavaScript RSS Reader © JavaScriptBank.comThis JavaScript code will display a HTML-formatted version of the RSS feed.

Full version: jsB@nk » Utility » JavaScript RSS Reader
URL: http://www.javascriptbank.com/javascript-rss-reader.html



JavaScript
<script language="JavaScript">////////////////////////////////////////////////////<JavaScript RSS Reader>//// (c) 2003 Premshree Pillai////Written on: 07/06/03 (dd/mm/yy)////http://www.qiksearch.com/////////////////////////////////////////////////////function readRSS(URI) {if(window.ActiveXObject) {var xmlDoc=new ActiveXObject("Microsoft.XMLDOM");xmlDoc.async=false;while(xmlDoc.readyState!=4) document.write('Loading...');}else if(document.implementation&&document.implementation.createDocument)xmlDoc=document.implementation.createDocument("","doc",null);xmlDoc.load(URI);items=xmlDoc;function verify() {if(xmlDoc.readyState!=4) return false;}function formatRSS() {var items_count=items.getElementsByTagName('item').length;var pubDate=new Array(), date=new Array, link=new Array(), title=new Array(), description=new Array(), guid=new Array();for(var i=0; i<items_count; i++) {if(items.getElementsByTagName('item')[i].getElementsByTagName('pubDate').length==1)pubDate[i]=items.getElementsByTagName('item')[i].getElementsByTagName('pubDate')[0];if(items.getElementsByTagName('item')[i].getElementsByTagName('dc:date').length==1)date[i]=items.getElementsByTagName('item')[i].getElementsByTagName('dc:date')[0];if(items.getElementsByTagName('item')[i].getElementsByTagName('link').length==1)link[i]=items.getElementsByTagName('item')[i].getElementsByTagName('link')[0];if(items.getElementsByTagName('item')[i].getElementsByTagName('guid').length==1)guid[i]=items.getElementsByTagName('item')[i].getElementsByTagName('guid')[0];if(items.getElementsByTagName('item')[i].getElementsByTagName('title').length==1)title[i]=items.getElementsByTagName('item')[i].getElementsByTagName('title')[0];if(items.getElementsByTagName('item')[i].getElementsByTagName('description').length==1)description[i]=items.getElementsByTagName('item')[i].getElementsByTagName('description')[0];}if((description.length==0)&&(title.length==0)) return false;document.write('<html><head><title>'+xmlDoc.getElementsByTagName('title')[0].firstChild.nodeValue+'</title></head><body>');document.write('<span style="font-family:verdana,arial,helvetica; font-size:8pt">');document.write('<center><a href="rss-reader.htm"><h3>[Go Back]</h3></a></center>');document.write('<center><a href="'+xmlDoc.getElementsByTagName('link')[0].firstChild.nodeValue+'"><h2>'+xmlDoc.getElementsByTagName('description')[0].firstChild.nodeValue+'</h2></a></center>');var ws=/\S/;for(var i=0; i<items_count; i++) {var pubDate_w, title_w, link_w;pubDate_w=(pubDate.length>0)?pubDate[i].firstChild.nodeValue:"<i>Date NA</i>";if(document.all)title_w=(title.length>0)?title[i].text:"<i>Untitled</i>";elsetitle_w=(title.length>0)?title[i].firstChild.nodeValue:"<i>Untitled</i>";link_w=(link.length>0)?link[i].firstChild.nodeValue:"";if(link.length==0) link_w=(guid.length>0)?guid[i].firstChild.nodeValue:"";if(title.length>0) title_w=(!ws.test(title_w))?"<i>Untitled</i>":title_w;if(pubDate.length==0) pubDate_w=(date.length>0)?date[i].firstChild.nodeValue:"<i>Date NA</i>";document.write('<a href="'+link_w+'"><b>'+title_w+'</b></a> <b>['+pubDate_w+']</b><br>');if(description.length>0)document.write('<font size="-1">'+description[i].firstChild.nodeValue+'</font><hr noshade><br>');}document.write('</span></body></html>');}if(typeof(xmlDoc)!="undefined") {if(window.ActiveXObject) formatRSS();else xmlDoc.onload=formatRSS;}}function checkString() {var loc=document.location.href.split("?")if(loc.length>1) {URI=loc[1].split("=");if(URI.length>1) {var retURI="";for(var i=1; i<URI.length; i++) retURI+=URI[i];try {readRSS(unescape(retURI));}catch(e) {}}}}</script><!--    This script downloaded from www.JavaScriptBank.com    Come to view and download over 2000+ free javascript at www.JavaScriptBank.com-->


HTML
<body onLoad="checkString();"><form name="form1" method="get" action="rss-reader.htm"><b>RSS URI: </b><input type="text" name="URI" value="http://" class="ip"><input type="submit" value="Read RSS" class="btn"></form></body><!--    This script downloaded from www.JavaScriptBank.com    Come to view and download over 2000+ free javascript at www.JavaScriptBank.com-->