It is working!
Press "F5" on your keyboard and a different banner should appear.
After two days of trying (yep very sad, but do I care!), I have finally modified my blogger template to do random roation on the banner graphics. If you don't get what I mean, press "F5" on your keyboard and a different banner should appear, if it happen to be the same banner then press again till you see a new one. It is a standard plug-in for Wordpress but we didn't have it in Blogger.... until now. Well I think this could be the first in the world of Blogger Beta, if not it is definitely my first hack anyway. Thanks Ramani from Hackosphere who gave me a few tips. Read on to see the scripts I have used.
I am not sure if it will works for all blogger templates, so I will just show you what I have done and you may have to modified it for your template. First of all I assume you have created a few graphical banners and have uploaded them onto a graphic hosting website.
For the 'Rounder' template I have used there is a piece of script in the CCS Style Section that read like this:
background:#476 url("http://www.blogblog.com/rounders4/bg_hdr_bot.jpg") no-repeat left bottom;
margin:0 0 0;
padding:0 0 8px;
Basically my script works by overwriting the 'background' definition at the <body> part of the template. I wrote the following right after the <body> tag:
var banner= new Array()
document.write(' background:url("' + banner[random] + '") no-repeat left TOP;');
My scripts above used Java Script to define an array of 5 url locations of the banners' graphic. Then the next line generate a random discret number between 0-4. The next part will generate some html codes to overwrite the "background" definition of the the "Header" style by selection a random banner everytime.
You will need to change the following:
1) The URL Locations of your graphics.
2) If you have 5 banners, you type "4" in the random number generating equation Math.round(4*Math.random()); If you have 3 banners type "2" and so forth.
Good luck, let me know if it works.
Sunday, October 15, 2006
It is working!