Click to See Complete Forum and Search --> : Need Code to Enable Banner Alteration using .js


lea
09-15-2003, 07:57 PM
Hi all, I'm new here and I'm having trouble with a particular code I've been trying to work out.

I've only recently figured out how to use .css pages and I've just figured out how to create a drop down menu for a fairly large site by accessing a .js code.

(the url is http://www.fictionfactor.com - check out the source code if you want to see my lame efforts at scripting)

I wanted this so that I could add or remove a link by only having to alter the one .js page, instead of the whole site.

Now my problem is this:

I have recently added banner advertising to the site, but I do not want to have to update 300+ pages every time a banner needs to be changed.

I can't find a script that will allow me to display the banners in a 'tower' like format, AND access the information from a single .js page as well.

I'm not a programmer, nor am I a web designer. I'm an editor who is trying to learn to update a high-maintenance site by only altering the one page.

Is anyone able to suggest a way to make images and their associated URL's load along the one left column by accessing a single .js page?

The site is currently a botch of HTML, too many tables and cells, some .css and some basic .js

Thanks in advance for any suggestions you might have.

Lea

gokou
09-15-2003, 10:15 PM
I've come up with a random banner script. It uses arrays to hold the images and links.

function banners() {
banners = new Array()
banners[0]="<img border=0 src=images/banner.gif>"
banners[1]="<img border=0 src=images/banner1.gif>"
banners[2]="<img border=0 src=images/banner2.gif>"

//links array
goto = new Array()
//put a real url in these
goto[0]="url"
goto[1]="url"
goto[2]="url"

//create a variable that will make the banners random
var number = Math.round(2 * Math.random());

//append the variable number to goto
var link = goto[number]
//append the variable number to banners
var image = banners[number]

//This is where you display the banners, there are
//better ways of doing it.

var dive = document.createElement("div")
dive.style.position="absolute";
dive.style.left="100px";
dive.style.top="300px";

//innerHTML doesn't work in netscape, so you might
//want to use something else. I don't know what
//else would work except for document.write();
/but if you put document.write inside a <td> tag,
//the banners won't show in netscape.
//I would also try putting it inside a <div> tag and
//using document.write(); with it, that might work.
dive.innerHTML="<a href=" +link+ ">" +image+ "</a>";
document.body.appendChild(dive);
}

I'll still mess with it and try to find other ways.

lea
09-16-2003, 12:03 AM
Thanks heaps, gokou.

I'll play with this and see what I come up with.

:D

Lea