Click to See Complete Forum and Search --> : banner rotater


swimflorida
02-18-2003, 09:24 PM
Hello,

I have a web site that uses frames and one of my frames have a [base target="_self"], but I'm trying to put in a banner rotater using Javascript. The problem is that I want it to open some of the links in the "main" frame and some of the banner links in new windows.

This is what I have so far, but I think I need to put in a line of code to tell it where I want it opened. I tried a few that I thought would work, but no luck (bannerone in a new window, bannertwo in the main frame):


.src="../images/USS/speedo1.gif"
document.links[0].href="http://www.speedo.com/"
setTimeout("bannertwo()",4000)
}

function bannertwo() {
document.images[0].src="../images/SwimFLConner2a.gif"
document.links[0].href="../Miscellaneous/Team_Sponsors.htm"
setTimeout("bannerone()",4000)
}




and then in I have this to 'activate' it in the site [body onload="reducespace();bannerone()"]

I used [] instead of <> so that it shows up better, but some places that have [] are supposed to have them, ie [0].

Sincerely,

swim florida

pyro
02-18-2003, 09:30 PM
Try this instead...

// Rotation list
function bannerone() {
document.images[0].src="../images/USS/speedo1.gif"
window.open("http://www.speedo.com/");
setTimeout("bannertwo()",4000)
}

function bannertwo() {
document.images[0].src="../images/SwimFLConner2a.gif"
top.thenameofyourframe.location.href="../Miscellaneous/Team_Sponsors.htm"
setTimeout("bannerone()",4000)
}

with thenameofyourframe being the name of the frame that you want your links to open in.

swimflorida
02-18-2003, 09:43 PM
Thank you Pyro.

I will try it right away.

Swim Florida

swimflorida
02-18-2003, 10:10 PM
Hello,

I got the links to open in the correct places, the thing is that as the banner rotates the links open automatically. I think I forgot to say that I only want the links to open when someone clicks on them.

This is the test folder where I'm testing it to see if I can get it to work before I put it on my site (unfortunately I have not taken enough time to learn enough JavaScript yet so I really appreciate all the help).

http://www.swimflorida.com/test2

Thank you,

Swim Florida

pyro
02-18-2003, 10:24 PM
For what you are trying to do, I'd do it like this instead.


// Rotation list
function bannerone()
{
document.getElementByID("banners").innerHTML = "<a href="http://www.speedo.com/" target="_blank"><img src="../images/USS/speedo1.gif"></a>
setTimeout("bannertwo()",4000)
}

function bannertwo(){
document.getElementByID("banners").innerHTML = "<a href="../Miscellaneous/Team_Sponsors.htm" target="yourframename"><img src="../images/SwimFLConner2a.gif"></a>
setTimeout("bannerone()",4000)
}And this goes in your first table cell.<div id="banners">
<a href="../home.html"><img border="0" src="../images/SwimFLConner2a.gif" width="140" height="70"></a></div>

swimflorida
02-18-2003, 10:41 PM
Thank you Pyro,

I will try this.

Swim Florida

swimflorida
02-18-2003, 11:03 PM
I tried that and it did not work either really. The banner(s) did not alternate any more. That could have been that the div took precedence over the onload command?

The link(s) open in the frame where banner rotator is, could be that the base target as something to do with it and it reads that instead of the targets in the code.

I’m just guessing what could have happened since I’m not sure what it really is.

Sincerely,

Swim Florida

pyro
02-18-2003, 11:09 PM
Oops, I gave you some bad code there...Try this instead.

// Rotation list
function bannerone()
{
document.getElementByID("banners").innerHTML = '<a href="http://www.speedo.com/" target="_blank"><img src="../images/USS/speedo1.gif"></a>';
setTimeout("bannertwo()",4000);
}

function bannertwo(){
document.getElementByID("banners").innerHTML = '<a href="../Miscellaneous/Team_Sponsors.htm" target="yourframename"><img src="../images/SwimFLConner2a.gif"></a>';
setTimeout("bannerone()",4000);
}Sorry about that. :rolleyes:

swimflorida
02-18-2003, 11:25 PM
I tried that and I still have the same problems.
On my old computer I have VB6, so sometimes it points to where it is an error, how reliable is that? Right now it points to
document.getElementByID("banners").innerHTML = '<a href="http://www.speedo.com/" target="_blank"><img src="../images/USS/speedo1.gif"></a>'

Not sure what it means more then I need to learn more.

PS. Thanks for all the help.

Swim Florida

pyro
02-18-2003, 11:29 PM
You need a semicolon at the end of that line.

swimflorida
02-18-2003, 11:31 PM
It is there, I just did not copy it because it was not highlighted in VB6.

swimflorida
02-18-2003, 11:40 PM
I want to thank you Pyro for your help, I will be back tomorrow. I got to get ready for morning practice in a few hours - need a little sleep.

Thanks

pyro
02-18-2003, 11:51 PM
getElementByID should be getElementById like this

document.getElementById("banners").innerHTML = '<a href="http://www.speedo.com/" target="_blank"><img src="../images/USS/speedo1.gif"></a>'

swimflorida
02-19-2003, 09:06 AM
I have tried this code, but it is not working for me, could the <div> block the onload so that the banner will not rotate?

the code in document.getElementById("banners").innerHTML = '<a href="http://www.speedo.com/" target="_blank"><img src="../images/USS/speedo1.gif"></a>';

I get an error, not sure what the error would be.

Swim Florida

swimflorida
02-19-2003, 10:58 AM
Why I don't change the base target for the frame to my main window (thenameofyourframe).

If I did this all the pages from the banner rotator as it was in the first post would load in thenameofyourframe, which would be ok. But then my Welcome script will not work for people if they want to change their greating name.

pyro
02-19-2003, 11:59 AM
Try this, it is working for me...

swimflorida
02-19-2003, 01:50 PM
Thanks Pyro,

That's working for me as well.

Swim Florida

swimflorida
02-19-2003, 07:36 PM
Hi,

I got it working and I like it a lot, but I have some questions that I wonder if anyone can answer.

The banner rotator does not work in Netscape 4.79, but it works well in 7.0.

As the images switch in the rotator the works with no problem in Netscape and in IE 5.5, but in IE6.0 there is about a half a second delay before the next image appears, is this something that has to do with IE 6.0 or do I need to have a different preload script?

I have not tested in Opera 6 or 7 yet (have downloaded but not installed them).

What other 'free' browsers are there out there that you can use without them interfearing with each other?

Sincerely,

Swim Florida

swimflorida
02-20-2003, 09:32 PM
Well so much for that problem, it helps if you have the best settings in your explorer. After changing my internet options from updating everything every visit to automaticly the banner works fine and I don't have any problem with getting the red X before every picture is displayed in the banner rotator.