
Adding a Random posts widget is very easy...
Simply log in to Blogger, go to Layout, click on "Add a Gadget", and select it as "HTML/JavaScript" type.
And finally paste this code in to it:
<script type="text/javascript">Edit the code shown in 'red' to change the number of posts being displayed in the widget.
var randarray = new Array();var l=0;var flag;
var numofpost=6;function randomposts(json){
var total = parseInt(json.feed.openSearch$totalResults.$t,10);
for(i=0;i < numofpost;){flag=0;randarray.length=numofpost;l=Math.floor(Math.random()*total);for(j in randarray){if(l==randarray[j]){ flag=1;}}
if(flag==0&&l!=0){randarray[i++]=l;}}document.write('<ul>');
for(n in randarray){ var p=randarray[n];var entry=json.feed.entry[p-1];
for(k=0; k < entry.link.length; k++){if(entry.link[k].rel=='alternate'){var item = "<li>" + "<a href=" + entry.link[k].href + ">" + entry.title.$t + "</a> </li>";
document.write(item);}}
}document.write('</ul>');}
</script>
<script src="/feeds/posts/default?alt=json-in-script&start-index=1&max-results=1000&callback=randomposts" type="text/javascript"></script>
Now save the widget, and place it somewhere so that it is clearly visible to the visitors !

Thanks to Blog Godown for this widget. Visit this blog to display the same widget along with summaries.
Image credits: AndApps
62 comments
Write commentsHi Mr Sai
ReplyThis is a little bit off topic, but I was wondering if you could help me with a query?
Is there any way when building a site on the blogger platform to include within a post a "browse box"? Something where you anybody visiting the site could click on a browse button within the post and then can browse to a particular folder / file on their hard drive and upload a picture, word doc or other file?
Obviously, if this can be done, any file uploaded would have to be able to go to some part of the web other than blogspot - is there functionality to call the file to a hotlink files or google sites account or similar?
Thank you very much for any help you can give with this.
Martin
Hello Martin,
ReplyYes that is certainly possible, check out this page for a live example:
http://bloggerstop.net/2008/09/contact-us.html
(see the second form-to send templates/any file to me)
In one of my posts, I have given the instructions to add a contact me page to blogger blogs. So by using the same method, while creating your "Contact Form" select to show only "one field" in the form, which is a "file attchment" type. Once you register there and start creating your form, you'll understand what I am saying.
But by this method, whatever files are uploaded by your readers will be mailed to you, so they will be stored in your mail-inbox, I hope that solves your purpose.
BTW, nice private policy page Martin :)
VERY VERY good widget, thanks a lot for this Divia
ReplyI'll try to show images on the widget too if i got some time
Replyoh yeah i am very happy u decides to use the defaut Blogger comment form.
ReplyI see u are changing the comment section style, good luck
Dear Sai,
ReplyI am having trouble with with my post that has not been updated since jun. When I check my blog status the last message appear like this.
(Friday, June 12, 2009 Blogger will be unavailable Monday (6/15) at 12:00AM PDT for about 10 minutes for maintenance.)
So what do I do to solve the problem because my blog list will not be updated to all my friends blog.
Tq.
Brianpedro
The link u give is a autoblogger...
Replywatch closely,he has just taken the feedburner E-mail delivery and he is posting by mail..HE has not even removed unsubscribe in some posts....you should not encourage this type of .people...remove that do-follow link..u are encouraging a plagiarism blog.
see the title from the archive ..you will understand..
Original source is here
http://hack-genius.blogspot.com/2009/07/random-post-widget-for-blogger.html
Sai Ramji Divya,
ReplyI was badly needing this widget. I will certainly use this widget.
Thanks a lot
Hetal Patil
Divya Sai looks like the place you got it from was also a content stealer because theoriginal code is here Random Posts Blogger Widget. http://www.bloggodown.com/2009/04/random-posts-blogger-widget.html
ReplyHi divya...
ReplyNice article....
Actually i had some questions.. Slight off topic...sorry
I have a blog at http://entrance-corner.blogspot.com/
but the problem is whenever any one searches or clicks on the labels category....the results arent given in a proper way....
u can check it out...try clicking on any labels....on my blog
Please tell me how to modify the search results page in blogger....like yours...how you have done it...?
i searched the whole "world wide web" but coulndt find any
I request you to please post something related to it....or give me the solutions for it.. http://us.i1.yimg.com/us.yimg.com/i/mesg/emoticons7/2.gif
Hi Divya
ReplyThank you for pointing me towards your own contact page and the e-mail me form website (I have previously used webformdesigner.com which does not provide captcha, nor the "browse box" function).
Thank you too for your kind comments about my privacy policy!
Sorry to stay off topic here but can you please clarify (because I cannot find the answer to this on the e mail me form website) - to build the form with that browse box, is that possible using the free service, or did you have to subscribe to one of their paid services?
Thank you in anticipation of your help with this.
Martin
The CV-Central sites are coming along nicely by the way!
Sorry to stay off topic b
@ Vinoth @ Gautam
ReplyThanks a lot guys for directing me to the original source, I have just updated and corrected the post.
@Manish
Here's the tutorial (It'll solve an important SEO purpose too):
http://bloggerstop.net/2009/01/show-only-titles-in-blog-archives-with.html
@Martin
It's all free, simply register and start making your forms(you can make multiple forms), simply give it a try, I am sure you'll like their service.
@ SinarHairan
ReplyCouldn't get your point...Your feed is working fine(as displayed in your "My Headlines" widget)
Moreover all the posts are getting indexed too by Google:
http://www.google.com/search?q=site%3Asinarhairan.blogspot.com
The Blog status message is actually not just specific to your blog, but it is for everyone hosted on Blogger. So don't worry about those messages, they are usually temporary and blogs go down for just around 10-20 minutes.
There are a lot of random posts gadgets out there, but yours is the one that works the way I want it to. Thanks!
ReplyHi.....THANK YOU ...........
ReplyAnyway, blogger is the most customizable blog platform in the world. Do you agree with me?
ReplyReza Winandar from Blogger Make Money
Hi the widget works great! I have a question though. How do I change the color of the links? I have a dark background and the links appear dark and it is hard to see. Thank you for your time.
Replyhttp://swwildspace.com/
@Matt
ReplyIn your template, you'll find this:
.tabdiv li {
list-style-image: url("star.png");
margin-left: 20px;
}
just below it, add this:
.tabdiv li a {
color: red;
}
NOTE: Instead of "RED", you may use any html-hex code by adding the code with a # prefix.
Thank you very much for your help!
ReplyThanks for the post. I post this to mine.
Replyhttp://csie-tw.blogspot.com/2009/10/bloggerrandom-post.html
thank it useful
Replynot working in my template.....
Replythanks friend, its really work until now! nice 2 see u... ;-)
ReplyIts perfect! thanks!
ReplyThis is a nice widget. Most of the other random post widgets around wouldn't work on my blog!
ReplyGlad it served your purpose :)
ReplyGreat Widget :D
Replythx useful
www.get2ware.co.cc
This is great! It works perfectly in Chrome but it's not working for me in IE. Is that just me?
ReplyTHIS GREAT DUDE......
ReplyTHANKS BRO!
Great post, thanks!!! :)
Replythank share
ReplyHi amd thanx for sharing.
ReplyThis widget works OK for me with Firefox, but does NOT work with Internet Explorer, nor with Chrome
Thanks bro!!!great widget
ReplyFantastic! Thank you for sharing this... it seems easy enough to implement and seems slightly better than the plain "random post" link!
Replybest widget random pos 4 blogspot thx:(
Replythanks alot for the script i really appreciate your work........good job..!!!
ReplyThat helped me a lot, you rock !!!
ReplyThanks Man!.
ReplyBy,
Free Hacking Tricks
thank you for this..
Replyvisit for free ebooks here http://dailyebookdownload.blogspot.com/
Useful widget, I'm just looking for it.
ReplyThx ;)
I want to know is there any way to include a ticker like random post widget which will rotate or animate the blog posts title with the link to the blog post unlike feedburner's headline animator which links to the feed url. I hope you are understanding what I am trying to say. for e.g BBC news website here http://www.bbc.co.uk/news/ titled "LATEST"
ReplyThank You :)
Cool hack.... My blog looks cool with this widget ;;)
ReplyExcellent widget - it's working perfectly.
ReplyOne question: how can I change the html so it says "random post" instead of the episode's name?
Thats attractive. and i want with thumbnail one,,
ReplyThe widget works fine in Firefox. In I.E., it works if I put the widget before Twitter Profile API. But if it is put after the Twitter, it doesn't work, means just empty. Any fix to this?
Replycan you tell us the code with thumnail random post
Replyhi
ReplyHi there,
ReplyThanks so much for posting this widget and tutorial.
It works like a charm on my blog.
MY QUESTION to you is - can I make the background white? Right now the red titles are hard to read over the pixelated image I am using as a background.
I see above how I can chang the colour of the text, but I don't see how to add a background or box around this random post widget.
Many thanks in advance. Great, informative, helpful blog!!
Yes you can do that (in fact not just a color background - but images as background too),
ReplyAlthough I have written the tuorial for popular posts widget, but you can do that for this random posts widget too....read it here:
http://bloggerstop.net/2009/02/new-customized-popular-posts-widget-for.html
I Can't use this script,, it makes my firefox become not responding :(
ReplyI just added this widget to my blog. You rock! :D
Replyhello...
Replyi was looking for this widget.. this widget is not working on my blog...
my blog is www.kuchkhaashai.com
could you please help me out....
thanks...
Hi Vijay, there's nothing much to edit or go wrong in this widget...it has been alreadu tailor made to fit in Blogger blogs.
ReplyThanks for this widget. I like it. I've used different one for random posts, but it somehow was making "traffic congestion" on my page.... This one is excellent... Thanks.
ReplyThanks for sharing this. I am using this on my blog and it's working perfectly! :)
Replythanks man i was really looking for this :D
Replynice widget but more nice if with img view.
Replythanks for share
No longer working. Please, update the script.
ReplyVery good widget, thank you!
ReplyIt works very good in my public blogs, though it doesn't work in "closed" blogs, that is, those blogs in which only authors can read the posts. Even being signed in as author, the widget doesn't work.
I doesn't work because the feeds are not available in this kind of blog.
Is it possible to solve this problem?
Maybe calling the feed in a different way?
Thank you!
Thanks for this, works perfectly fine.
ReplyI post the script as u tell and i am able to solve the problem thanks sir
ReplyComments are moderated on this blog
Allowed HTML tags: <b>, <i> and <a>
Comment Like This! and Optimize your blog EmoticonEmoticon