Welcome to WebmasterWorld Guest from

Forum Moderators: incrediBILL & martinibuster

Message Too Old, No Replies

A banner rotator for Adsense and another Ad?

Script for bannor rotator compatible with Adsense



9:36 pm on Jun 1, 2005 (gmt 0)

10+ Year Member

I have searched for this everywhere and for ages now but cant find one.

Basically what I'm looking for is a script that allows Google Adsense and another Ad like Clicksor etc. to be rotated.

Since my site is in normal html it cant be php or other. So I'm looking for something along the lines of in javascript and looks up a txt file and rotates the ads accordingly.

Is this possible, I mean it should be, but cant find anything suited for my purpose.


10:26 pm on Jun 1, 2005 (gmt 0)

10+ Year Member

i know this isn't exactly what you are looking for, but i am suggesting it in case you didn't know about it... you could use google's "alternate url" to show alternative ads whenever there aren't google ads to display:



11:31 pm on Jun 1, 2005 (gmt 0)

10+ Year Member

Try searching for phpadsnew.

It's all good!


11:35 pm on Jun 1, 2005 (gmt 0)

10+ Year Member

Is it not against the TOS?


11:46 pm on Jun 1, 2005 (gmt 0)

10+ Year Member

as long as you dont modify the adsense code, its not against TOS. but php ads new wont help him. he wants a javascript.

im kind of interested if he finds anything. my front page is plain html to cut down on server load.


11:50 pm on Jun 1, 2005 (gmt 0)

10+ Year Member

This doesn't sound like it would be terribly hard to make in JavaScript. You'd have all code assigned to an array of variables, then randomly (or whatever weight you'd want to build in) pick which to display, and then do a document.write() of the selected ad where appropriate. Sounds like it could be done in less than 15-20 lines of JS.


12:18 am on Jun 2, 2005 (gmt 0)

10+ Year Member

Yeah... just because I wanted to see just how simple the JS would be... here you go. Was less than 20 lines (mostly just the ad code:


I've removed my own ID's from the code (look for X's and Z's). Feel free to swipe the code and use where you will. The only thing I had to do was condense the Google Ad Code down to one line. This is technically in violation of TOS, although, I'm sure you can get JavaScript to output it the proper way with some newlines put in there..


[edited by: Jenstar at 4:02 pm (utc) on June 2, 2005]
[edit reason] No URLs as per TOS [/edit]


12:19 am on Jun 2, 2005 (gmt 0)

10+ Year Member

Oh yeah... hit reload of a few times to see the random rotation.


12:23 am on Jun 2, 2005 (gmt 0)

10+ Year Member

sweet, thanks diverman.


12:46 am on Jun 2, 2005 (gmt 0)

10+ Year Member

No problem. glad to help. I'd actually been wondering about doing something like this myself for other things, although I'd likely do it in PHP or some other language with a DB backend, and weighted rotation. I'm sure you probably could find another implementation that may be more robust that what I whipped up in a few seconds. Try a google search or something to see if you can find more. :)


9:53 am on Jun 2, 2005 (gmt 0)

10+ Year Member

Ok thanks alot everyone for your input. As far as I know its not in the TOS so it should be ok. Its funny how your not allowed to put a competitors ad in as an alternative ad but nothing about a rotator of some sort.

Anyway I'll give the script a go and I'll post the results. Thanks again diverman.


1:20 pm on Jun 2, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member

Very slick. I am having fun with it.

Thanks a bunch.


2:38 pm on Jun 2, 2005 (gmt 0)

10+ Year Member

long time since I had an adsense account but from memory adbutler(do a google search) was able to rotate a wide variety of banner types and I think As was one of them.

Featured Threads

Hot Threads This Week

Hot Threads This Month