Embed RSS feed as javascript to the webpage

Posted by Andi Syahputra | 2:52 PM
I just found one cool tools that will convert headline from RSS feed directly to javascript version so you can embed it into your webpage. Usually you need JSON to fetch the feed then parse it as javascript. But JSON create a bunch of big file that may slow the webpage.

You can goto RSS to javascript homepage then create your own javascript. It's totally free. All you need is just paste the feed url then generate javascript after you set your own setting there. Easy to use and faster than JSON because it not create a big file like JSON does.... :D

Anyway, if you more prefer JSON than RSS to javasript, here is RSS fetch in JSON version:

<script type="text/javascript">
function recentpostslist(json) {
document.write('<ul>');
for (var i = 0; i < json.feed.entry.length; i++)
{
for (var j = 0; j < json.feed.entry[i].link.length; j++) {
if (json.feed.entry[i].link[j].rel == 'alternate') {
break;
}
}
var entryUrl = "'" + json.feed.entry[i].link[j].href + "'";//bs
var entryTitle = json.feed.entry[i].title.$t;
var item = "<li>" + "<a href="+ entryUrl + '" target="_blank">' + entryTitle + "</a>";
document.write(item);
}
document.write('</li>');
}
document.write('</ul>');
</script>

<script src="http://fun-tutorial.blogspot.com/feeds/posts/default?max-results=10&alt=json-in-script&callback=recentpostslist"></script>

Change the feed address as you want.
Very simple right? :D
hi folks, visit my other tutorial blog at Kumpulan tutorial menarik
0 comments