My button uses the following. It produces a random post within my blog whenever a user clicks it.
<div id="myLuckyPost" class="random button"></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 = '<center><span id="icon-random"></span></center><span class="visible-lg">Random</span>'; document.getElementById('myLuckyPost').appendChild(a); } </script> <script src="/feeds/posts/summary?max-results=0&alt=json-in-script&callback=feelingLucky"></script>
I'd like for this button to automatically be clicked whenever someone enters through my homepage so my visitors can get right into the thick of things. So far this is what I've found:
<script>
window.setTimeout('clickit()',5000);
function clickit(){
location.href = document.getElementById("autoid");
}
</script>
I'm just not sure where to put the ID, and what it should be. I've tried a few things to no avail. Thanks a ton to anyone who is able to help.