Gadget, Free Software, Reviews

Easy Banner Rotator using Javascript

October 21st, 2008 · No Comments

In order to provide rotating ads banner on this blog, I was using php banner rotator code until I began to use wp-super cache plugin. Since the wp-cache plugin creates an html static page version from every php page, every php command of those page only executed once and that’s why the php banner rotator no longer working properly. The banner will not change until the cached page deleted or refreshed with a new one.

I finally realized that wp-cache only creates a static page from php code but any javascript code would still be executed this applies to banner rotator as well. If I’m using a javascript code instead of php code then my banner will rotates normally no matter how long the page’s cache last.

I found a simple banner rotator using javascript code from and it easy to use. All you need to do is placing the following code on position you want and edit the image link and the anchor link as well. Now you can enjoy the benefit of wp-super cache plugin while retaining the functionality of image / banner rotator on your page.

The banner rotator java script code

<script language=JavaScript>
| Ad Simple Copyright |
| This program may be used and hosted free of charge by |
|anyone for personal purpose as long as this copyright |
|notice remains intact. |

var img_width = "300";
var img_height = "250";
var img_title = "Alternate Image Title";

var ad=new Array()
//insert here your images src

var links=new Array()
//insert here your links

var xy=Math.floor(Math.random()*ad.length);
document.write(‘<a href="’+links[xy]+’" target="_blank" rel="nofollow" ><img src="’+ad[xy]+’" width="’+img_width+’" height="’+img_height+’" alt="’+img_title+’"></a>’);

The original code was from

Related posts:

  1. More Photo of Lenovo Thinkpad X200
  2. How to unregister a dll file safely in Windows
  3. New picture of Motorola Z10 Handset
  4. Macbook Protective Cover from Bird Electron
  5. Download Alizée Jacotey wallpaper for Windows
  6. PHP Code For Banner Rotator
  7. Using mod-rewrite .htaccess redirection
  8. The Importance of a Sitemap on Gatzet Info
  9. Defeating Spams On WordPress
  10. JPEG Image Rotator

0 comments for this entry ↓

  • There are no comments yet for this entry.

Leave a Comment