Follow by Email

Thursday, March 1, 2012

Random gadgets for Bloggers


It is an interesting thing to show random messages or pictures or ads in the Website. you may love to show different messages on the same page when user visit same page again. That may be your picture, which have different pose on every refresh. Even that can be a blogger gadgets, on every refresh on the same page you can make to get random gadgets. This type of Randoming will make different look on your pages. Let see how to make random elements




Code:
<div id="Randomme" style="display: none;">
......
</div>
<div id="Randomme" style="display: none;">
......
</div>
<div id="Randomme" style="display: none;">
......
</div>
<script language="JavaScript">
Randomme[Math.round(Math.random()*(Randomme.length-1))].style.display="block";
</script>

This is the Basic syntax for the random contents. Note that highlighted dots are the space for your contents. That can be a HTML. Below is the unit content and you can add n number of contents that you wish.so final output will be any one from these whole content in random pick.
<div id="Randomme" style="display: none;">
......
</div>

How to add?
First select your contents(Pictures or Message with HTML format) and fill the above syntax.
you can add it directly to your Blog template where you need this effect
For Blogspot site, you can also add this codes in Template-> add Gadget-> HTML/JavaScript

Applied Examples:
Below is the code which display below effect

<div id="Randomme" style="display: none;">
I use <a href="http://google.com">Google</a>
</div>
<div id="Randomme" style="display: none;">
I like to blog about webdesign and Cartoons/Paintings 
</div>
<div id="Randomme" style="display: none;">
Thanks for visiting My blog. Please Visit me again</br>
<a href="http://4.bp.blogspot.com/-TKxgtK6Fi9k/T1A2CvZ_SvI/AAAAAAAAAD8/qSHbMaH4inw/s1600/Macrolayer.jpg" imageanchor="1" style="clear:left; float:left;margin-right:1em; margin-bottom:1em"><img border="0" height="89" width="320" src="http://4.bp.blogspot.com/-TKxgtK6Fi9k/T1A2CvZ_SvI/AAAAAAAAAD8/qSHbMaH4inw/s320/Macrolayer.jpg" /></a>
</div>
<div id="Randomme" style="display: none;">
If you are the new blogger read me <a href="http://macrolayer.blogspot.com/2011/10/five-steps-for-new-bloggers.html">5 Tips for you</a>
</div>
<div id="Randomme" style="display: none;">
<img src="http://2.bp.blogspot.com/-4Mv09s2KMBg/Tn_piBfywQI/AAAAAAAAToc/-ZfaSO0oJzU/s1600/0GetHer.gif" /></div>
<div id="Randomme" style="display: none;">
<!-- Place this tag in the <head> of your document -->
<link href="https://plus.google.com/108072841148840858643" rel="publisher" /><script type="text/javascript">
window.___gcfg = {lang: 'en'};
(function() 
{var po = document.createElement("script");
po.type = "text/javascript"; po.async = true;po.src = "https://apis.google.com/js/plusone.js";
var s = document.getElementsByTagName("script")[0];
s.parentNode.insertBefore(po, s);
})();</script>
<g:plus href="https://plus.google.com/108072841148840858643" width="300" height="131" theme="light"></g:plus></div>
<script language="JavaScript">
Randomme[Math.round(Math.random()*(Randomme.length-1))].style.display="block";
</script>




Demo:



Refresh this page to see the difference.

2 comments:

  1. 〈img id="myimage" onclick="if (document.getElementById('myimage').src=='http://www.w3schools.com/dhtml/bulboff.gif'){document.getElementById('myimage').src='http://www.w3schools.com/dhtml/bulbon.gif';}else{document.getElementById('myimage').src='http://www.w3schools.com/dhtml/bulboff.gif';}" border="0" src="http://www.w3schools.com/dhtml/bulboff.gif" width="100" height="180" /〉

    ReplyDelete
  2. Thanks for a very interesting blog. What else may I get that kind of info written in such a perfect approach? I’ve a undertaking that I am simply now operating on, and I have been at the look out for such info. outdoor gadgets

    ReplyDelete

You Can use HTML code once it converted to NCcode by NCode converter