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 YugDesign.com 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> var img_width = "300";
/*
+———————————————————+
| Ad Simple Copyright www.YugDesign.com |
+———————————————————+
| 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_height = "250";
var img_title = "Alternate Image Title";
var ad=new Array()
//insert here your images src
ad[0]=’http://imagedos.net/images/1.gif’;
ad[1]=’http://imagedos.net/images/2.gif’;
ad[2]=’http://imagedos.net/images/3.jpg’;
ad[3]=’http://imagedos.net/images/4.gif’;
var links=new Array()
//insert here your links
links[0]=’http://www.gatzet.com/go/computergeek’;
links[1]=’http://www.gatzet.com/go/freedownload’;
links[2]=’http://www.gatzet.com/go/braintrain’;
links[3]=’http://www.gatzet.com/go/gamesdownload’;
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>’);
</script>
The original code was from YugDesign.com












0 comments for this entry ↓
There are no comments yet for this entry.
Leave a Comment