I need a free ad banner rotator. Like a code that I can just insert in the ad space of my template.
Any suggestions????

Dani AI

Generated

For a small banner slot like you asked, first settle the behaviour: rotate while the page is open, or show a different image on each refresh? already flagged that distinction and it matters for the implementation and performance choices. Also note that the Flash suggestion from is out of date — Flash was discontinued (end‑of‑life) and should not be used.

Modern, practical options:

  • For in‑page rotation (slideshow): use a lightweight CSS/HTML approach or a tiny JS slider so mobile CPU and battery use stay low. Pause animations when the ad leaves the viewport (use Intersection Observer) to avoid wasted cycles and missed metrics. See the Intersection Observer guide on MDN for patterns and examples (good for pause/resume): Intersection Observer API.
  • For per‑refresh rotation: server‑side random selection or a redirect that counts impressions is simplest and reliable when tracking matters.

Asset, accessibility and tracking tips:

  • Resize and compress images (WebP where supported) and serve responsive sizes with srcset. Use loading="lazy" on non‑above‑the‑fold assets to reduce initial load.
  • Preload the next slide to avoid flicker. Use semantic markup and ARIA labels so keyboard users and screen readers can make sense of the ad region.
  • Expect ad blockers to block some scripts; for critical impression tracking prefer a server‑side counter or a simple redirect URL rather than client‑only JS counting.

If you want a ready library, consider a maintained lightweight slider (e.g., Swiper) for features like touch support and accessibility. For full ad management (campaigns, reporting) use a maintained adserver rather than phpAdsNew — Revive Adserver is the modern open source option.

Quick checklist for : decide rotation type, prepare optimized assets, implement slider (or server randomizer), add viewport pause, and test on mobile + with common ad blockers.

Recommended Answers

All 6 Replies

Do you mean one that keeps rotating whilst the page is being used or one that displays a different ad(image) each time you refresh the page.

Do you mean one that keeps rotating whilst the page is being used or one that displays a different ad(image) each time you refresh the page.

Yes, thats what I meant.

Member Avatar for Member #46692

Ideally you would have the banner slideshow in either flash or javascript. Flash preferred.

Then on your side (i.e. on the server side) you would use a random script generated in php or something similar. Of course it could all be done on the client side using javascript - but I wouldn't.

I am very much not a fan of phpAdsNew. On all but the smallest sites it is rather sluggish, and the code is very inefficient. Unfortunately I don't have any other free solutions for you either, though.

I still can't tell whether you want to rotate an ad or a image?

If it is an image there are alot of codes on the web but this one may help you:

Put the following code where you would like the image to appear:

<script type="text/javascript" src="rand.js">

Then save the following javascript as "":

// JavaScript Document

var mess = new Array('<img src="pathtoimage.jpg" alt="IMAGE TItle" name="Name" width="276" height="181"/>','<img src="image_path.jpg" alt="Image Title" name="NAME" width="274" height="181"/>');
var max = mess.length;
var num = Math.floor((Math.random() * max));
document.writeln(mess[num]);

There are only two images here but you can use as many as you like, just seperate by comma.


Hope that helps you.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.