28 March 2010

Random Posts Widget For Blogger

How can I get this widget.
Sign in to Blogger > Layout > Page Elements > Add a
Gadget > HTML/Java Script..
Now add following code in that

<div id='myluckypost'></div> <script
type='text/javascript'> function showLucky(root){ var feed = root.feed; var
entries = feed.entry || []; var entry = feed.entry[0]; for (var j = 0; j <
entry.link.length; ++j){if (entry.link[j].rel == 'alternate'){window.location
= entry.link[j].href;}}} function fetchLuck(luck){ script =
document.createElement('script'); script.src = '/feeds/posts/summary?start-index='+luck+'&max-results=1&alt=json-in-script&callback=showLucky';
script.type = 'text/javascript'; document.getElementsByTagName('head')[0].appendChild(script);
} function feelingLucky(root){ var feed = root.feed; var total =
parseInt(feed.openSearch$totalResults.$t,10); var luckyNumber =
Math.floor(Math.random()*total);luckyNumber++; a = document.createElement('a');
a.href = '#random'; a.rel = luckyNumber; a.onclick =
function(){fetchLuck(this.rel);}; a.innerHTML = 'View Random Post';
document.getElementById('myLuckyPost').appendChild(a); } </script> <script

Now save it.
numofpost=7 - It shows no. of random posts to be displayed.
wordnumber=5 - It shows length of post summary


Technorati Digg This Stumble Stumble Facebook Twitter

Get Our Quick Updates!

Follow us!


Post a Comment


About The Author

Hi! I am the man behind this blog, a professional Blogger, Web Designer, SEO Consultant, Computer Engineer and an addicted Web Developer.

eXTReMe Tracker

Support Us

If our of different IT related Tips & Uploads has providing help to you, and you like these then please spread our word using this badge below and attach this on your blog / website:-

| My Technology Updates © 2009-2012 All Rights Reserved | Contact us | Sitemap | Back To Top |