I want to have a corner on my blog which show pictures that change everytime the reader clicks on refresh or on a link.How do you put up random changing pictures on your blogger template?
It really depends on if you're using Bloggers blogspot space or if you're FTPing to your own site. Assuming that you've got a blogspot.com account, you can try the following javascript:
%26lt;script type=';text/javascript';%26gt;
images = new Array(4);
images[0] = 'http://www.somedomain.com/image1.gif';
images[1] = 'http://www.somedomain.com/image2.gif';
images[2] = 'http://www.somedomain.com/image3.gif';
images[3] = 'http://www.somedomain.com/image4.gif';
rnd = Math.floor(Math.random() * images.length);
document.write('%26lt;img src=';'+images[rnd]+'';%26gt;');
%26lt;/script%26gt;
Things to note:
1. The number in the Array() is how many images you want to cycle through.
2. Use the full URL of where the images are kept. It's good practice not to ';steal'; images from other sites, but if you don't have a space to keep them yourself, you can use something like Flickr (www.flickr.com).
3. The images will display where ever you insert the code.
4. Disregard the '....' after the image URLs in the example - that's just something Yahoo Answers put in, not me :-)
Hope this helps.
Subscribe to:
Post Comments
(Atom)
No comments:
Post a Comment