Can someone link me to a script that will rotate an ad banner on a website so a different ad appears when you refresh or revisit the page. I have a found a few scripts that rotate images but it has to be able to have the link with it too. Thanks.

Recommended Answers

All 4 Replies

Member Avatar for GreenDay2001

Which one do you want ASP, PHP, javascript.

Javascript preferably, or else php. Thanks!

Got it, thanks though!

<SCRIPT language=JavaScript>
/*
 +---------------------------------------------------------+
 | 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_width = "468";
var img_height = "60";
var img_title = "Click Here";


var ad=new Array()
//insert here your images src
ad[0]='gray.jpg';
ad[1]='red.jpg';
ad[2]='black.jpg';

var links=new Array()
//insert here your links
links[0]='http://www.google.com';
links[1]='http://www.yahoo.com';
links[2]='http://www.gmail.com';

var xy=Math.floor(Math.random()*ad.length);
document.write('<a href="'+links[xy]+'" target="_blank"><img src="'+ad[xy]+'" width="'+img_width+'" height="'+img_height+'" alt="'+img_title+'" border="0"></a>');
</SCRIPT>
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.