Monday, May 16, 2011

HTML Tricks - Create Random 468x60 AD Banners Widget



Article author: Alwyn Ash
"At the right time, in the right light, everything is extraordinary"



Woman with laptop image




Ever wanted to advertise via 468x60 AD banner but with a difference - the banners are displayed randomly, allowing various advertisements to appear each time the webpage refreshes? Easily done!

Simply copy the code below and paste it into a HTML/JavaScript widget:



<script language="JavaScript">
images = new Array(3);
images[0] = "<a href = 'URL OF ADVERTISER' rel='nofollow' ><img src='URL OF BANNER’S IMAGE-1' border='0' height='60px' width='468px' alt='AD DESCRIPTION'></a>";
images[1] = "<a href = 'URL OF ADVERTISER' rel='nofollow' ><img src='URL OF BANNER’S IMAGE-2' border='0' height='60px' width='468px' alt='AD DESCRIPTION'></a>";
images[2] = "<a href = 'URL OF ADVERTISER' rel='nofollow' ><img src='URL OF BANNER’S IMAGE-3' border='0' height='60px' width='468px' alt='AD DESCRIPTION'></a>";
index = Math.floor(Math.random() * images.length);
document.write(images[index]);
</script>


Replace the red code with your advertiser's URL. Replace the code in blue with a link to your banner image source. Also feel free to change the size(s) of the banners from 468x60 to whatever you wish - just remember to keep each banner identical in size to the rest!


Source: My Blogger Tricks.