Closed Thread Icon

Topic awaiting preservation: Banner Image Swap - now need url swap Pages that link to <a href="https://ozoneasylum.com/backlink?for=24104" title="Pages that link to Topic awaiting preservation: Banner Image Swap - now need url swap" rel="nofollow" >Topic awaiting preservation: Banner Image Swap - now need url swap\

 
Author Thread
Karl
Bipolar (III) Inmate

From: Phoenix
Insane since: Jul 2001

posted posted 11-19-2004 05:41

Hi,

My image swapping seems to be working fine:
http://www.hardrockinvitational.com/default.asp

I have the array "aUrl" and it contains the URL's for the corresponding banners. I can't figure out how to swap out the href attribute of the anchor tag. I'm sure this is simple. This didn't work:

document.BANNER_LINK.setAttribute('href') = aUrl[imageNum];

Thanks for the help!

Karl

bitdamaged
Maniac (V) Mad Scientist

From: 100101010011 <-- right about here
Insane since: Mar 2000

posted posted 11-19-2004 06:06

Usually you just call some sort of function that switches the URL in a variable with the images. (or a counter)

So

code:
var aImg = new Array();
var aUrl = new Array();
var delay = 5000;
var imageNum = 0;

preLoadBanners();

function preLoadBanners() {
aImg[0] = new Image();
aImg[1] = new Image();
aImg[0].src = "/images/trammel_crow_banner.gif";
aImg[1].src = "/images/acacia_banner.gif";
// aUrl[0] = "http://www.trammelcrow.com/home.asp";
// aUrl[1] = "http://www.acaciafinancial.com";
}

function swapBanners() {
imageNum++
if(imageNum > 1) {
imageNum = 0
}
document.BANNER_IMG.src = aImg[imageNum].src;
}



function goToUrl() {
document.location.href = aUrl[imageNum];
return false;

}

Then just in your link you do

<a href="firstUrl.html" onClick="return goToUrl()">Link</a>



That of course is your code. I swapped around where the imageNum gets updated because I need it to be the current ImageNum not the next one. Also this should degrade gracefully.



.:[ Never resist a perfect moment ]:.

(Edited by bitdamaged on 11-19-2004 06:08)

Karl
Bipolar (III) Inmate

From: Phoenix
Insane since: Jul 2001

posted posted 11-19-2004 06:39

Well that worked perfect! Thanks a bunch.

« BackwardsOnwards »

Show Forum Drop Down Menu