In the course of my work, I’ve created and refined a simple ad rotator. It is built in JavaScript, and does not rely on any library, like jQuery, to function. In my experience, it defeats ad-block, and loads easily on all mobile, tablet, and desktop browsers.
The rotator can be included multiple places on one page without any conflicts or collisions, so just drop-in where needed. Some coding is required to customize — basically copying and pasting your links and image urls, but nothing too heavy.
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
(function(){ // Simple Rotator // Michael Jasper, 2013 // http://www.mikedoesweb.com/2013/quick-and-reliable-ad-rotator/ var Advertisements = { count:2, ads:{ 0:{ image:"http://www.example.com/image1.jpg", link:"http://www.google.com" }, 1:{ image:"http://www.example.com/image2.jpg", link:"http://www.google.com" } } }; var selection = Math.floor(Math.random()*Advertisements.count); document.write("<a href='" + Advertisements.ads[selection].link + "'target='_blank'>"); document.write("<img src='" + Advertisements.ads[selection].image + "'>"); document.write("</a>"); })(); |