View Full Version : is this easy to make ?
08-26-2002, 11:35 PM
I'm looking for a banner rotater of my own, in any lanugage, CGI/PHP/JAVA script...
i just need it to change banners if someone refreshes the screen, and then a new banner is there :)
also to be able to edit the size of the banner,
I dont knwo if this is easy or not to mak e,,
Thanks for your help :)
08-27-2002, 12:08 AM
Yeah! It's very easy! you have to make a random function that generates some numbers and based on those numbers, you can change your banners onload. let's say you have 3 images with the follwoing dimensions:
Name : Image1.jpg , Dim = 100px * 100px
Name : Image2.jpg , Dim = 132px * 58px
Name : Image3.jpg , Dim = 58px * 73px
ourRand = Math.floor(Math.random() * 3);
switch ( ourRand )
case 0 :
"<img src='Image1.jpg' width='100' height='100'>";
case 1 :
"<img src='Image2.jpg' width='132' height='58'>";
case 2 :
"<img src='Image3.jpg' width='58' height='73'>";
<body onload = "Init()">
I didn't test what I wrote, but it has to work!
08-27-2002, 12:37 AM
That won't work cross-browser - but you can use the same kind of randomness to simply document.write a banner on the page each time.
08-28-2002, 06:55 PM
Thankx for the code.
whammy u said it work cross-browser , what do u mean by that ??
08-28-2002, 07:16 PM
This should work in all browsers. The previous script would only work in IE5 and NS6 and above.
08-29-2002, 12:56 AM
Just a question, you said that my code doesn't work in IE5- and NS6- and I admit, but just imagine that he/she wanted to write a code that changes an element of the page, let's say in a kinda period, WITHOUT reloading the whole page, what I'm asking is that is there a way to do this without using "innerHTML" or "nodeValue"? document.write works fine if you wana put something in the page and do not change it, but what if...
08-29-2002, 01:55 AM
you use the image.src and link.href properties. both are read/write. i've written this same kind of script, using both of those. my technique was to set up a 2d array of image urls and link urls, pick a random number, stick it in the array, and then use array[random] and array[random] to set the picture and link. if you do a search in the old forum, you'll find it once or twice.
Powered by vBulletin® Version 4.2.2 Copyright © 2016 vBulletin Solutions, Inc. All rights reserved.