Siczine.com - 1-31-2008 at 07:08 PM
Web Banner Code
I am trying to get more rotating banners and this code should do that, however, I am not quite sure what "//store the quotations in arrays" means.
Any help is greatly, greatly appreciated.
Siczine.com - 1-31-2008 at 07:08 PM
The above example is images of some of our different advertisers. If you refresh or reload the page in your browser, you should get a different image
(if you get the same, try again.) We wrote this basic script to allow viewers of your web page to get a new look each time they come to your web page.
Source code
BDx13 - 1-31-2008 at 07:35 PM
right now, you have four arrays, numbered 0, 1, 2, and 3.
if you want a wider variety of banners to display, you need to define the number you want, then define the details of each. so...
- change the number in "images = new Array(4);" to the number of banners you want to display. You want 12 different ads, make it "images = new
Array(12);" (without the quotation marks).
- then repeat "images[3] = "
";" (again, without the double quotes) a total of 12 times. be sure to change the number at the beginning, the URL
to which you want to direct your users when they click (that's the a href part) and the location of your banner ad (that's the img src part).
BDx13 - 1-31-2008 at 07:45 PM
lemme know if that's unclear, and i can try again.
Siczine.com - 2-1-2008 at 05:51 PM
Okay, so say I want four, is this what the part of code I would put in?
images = new Array(4)
images[0] = "
";
images[1] = "
";
images[2] = "
";
images[3] = "
";
index = Math.floor(Math.random() * images.length);
document.write(images[index]);
//done
// -->
Siczine.com - 2-1-2008 at 05:51 PM
Thanks for the help too by the way BD.
Siczine.com - 2-1-2008 at 05:56 PM
I'm a retard. But I finally got it. Thanks BD!
BDx13 - 2-1-2008 at 06:11 PM
yeah, you were just missing the top part that identifies the code a javascript.
so you got it working? if you need any other help, send me a u2u and i'll hook it up for ya.
Siczine.com - 2-1-2008 at 06:19 PM
Yo BD, one last question. Everything is fine but is there anyway I can get rid of the blue boarders?
BDx13 - 2-1-2008 at 06:36 PM
there is a border property for images that sets the size of the border around an image. by default, it's one pixel, but you can remove it by setting
it to zero:
img src='http://www.computerhope.com/banners/banner4.gif' alt='Computer Hope Newsletter' border='0'
just don't forget the beginning and end carrots (the < and > ) . If i include them in my post, it's not simply displaying the code, but actually
rendering it.
Siczine.com - 2-1-2008 at 07:14 PM
Yeah for some reason I figured because it had "//Javascript Created by Computerhope http://www.computerhope.com
//store the quotations in arrays" that all that should be excluded, completely forgetting most codes that end with a > need to begin with a <.
And thanks for the tip about the boarders, got that to work as well!
BDx13 - 2-2-2008 at 04:19 PM
great, glad to hear it.