webForumDet fria alternativet

Jojoxx bildväxlingsscript

JavaScript

5 svar · 374 visningar · startad av joakimweb

Medlem sedan feb. 2002141 inlägg
Frågan#1

Hej!

Jag ska ha en bannerväxlare och såg bland jojoxx alltid lika snygga scripts att det fanns just ett sådant. Men problemet är att jag vill länka bilderna, och dessa länkar vill inte riktigt hänga med.

Banner1:s länk visas
Banner2 visas och länken byts
Banner1 visas igen men länken är fortfarande banner2:s.

<div style="height:60px;width:468px;">
<div id="fadea" style="position:absolute;visibility:hidden;"><a href="http://www.joakimweb.se" target="_blank"><img src="/assets/images/jw.gif" width="468" height="60" border="0"/></a></div>
<div id="fadeb" style="position:absolute;visibility:hidden;"><a href="http://www.webcows.se" target="_blank"><img src="/assets/images/webcows.gif" width="468" height="60" border="0"/></a></div>
</div>

<script type="text/javascript">
/*  The code contained in this  file is copyrighted by [url]www.jojoxx.net[/url]
The file may be used for none commercial applications and distributed
as long as these lines remain intact.  The file or part of it may not
be sold  or  included  in any  other commercial  application  without
agreement from the author. If you have questions or comments, contact
the author at [url]http://www.jojoxx.net[/url]

© Copyright - [url]www.jojoxx.net[/url] - 2004                                */

var divs=["fadea","fadeb"];
function fade(n,diff,opacity){
	id=divs[n];
	opacity=(opacity)?opacity:(diff<0)?100:0; opacity+=diff;
	if(document.getElementById&&document.all){
		document.getElementById(id).style.filter="alpha(opacity="+opacity+")";
	}else if(document.getElementById&&!document.all){
		document.getElementById(id).style.MozOpacity = opacity/100;
	}
	document.getElementById(id).style.visibility="visible";
	if(opacity>=100){
		setTimeout("fade("+n+",-"+diff+","+opacity+");",5000);
		nn=(n==divs.length-1)?0:n+1;
		setTimeout("fade("+nn+","+diff+");",5000);
	} else if(opacity>0){
		setTimeout("fade("+n+","+diff+","+opacity+");",30);
	}
}
fade(0,1);
</script>

Hoppas någon har tid och lust att hjälpa mig.
Tack på förhand

/Joakim

Medlem sedan juni 20004 308 inlägg
#2

Scriptet var för början bara tänkt som en bildfade. Har modifierat det lite så att när varje bild är fullt synlig läggs det lagret överst (och således kommer även länken att fungera).

<script type="text/javascript">
/*  The code contained in this  file is copyrighted by [url]www.jojoxx.net[/url]
The file may be used for none commercial applications and distributed
as long as these lines remain intact.  The file or part of it may not
be sold  or  included  in any  other commercial  application  without
agreement from the author. If you have questions or comments, contact
the author at [url]http://www.jojoxx.net[/url]

© Copyright - [url]www.jojoxx.net[/url] - 2004                                */

var divs=["fadea","fadeb","fadec"];
var zindex=0;
function fade(n,diff,opacity){
	id=divs[n];
	opacity=(opacity)?opacity:(diff<0)?100:0; opacity+=diff;
	if(document.getElementById&&document.all){
		document.getElementById(id).style.filter="alpha(opacity="+opacity+")";
	}else if(document.getElementById&&!document.all){
		document.getElementById(id).style.MozOpacity = opacity/100;
	}
	document.getElementById(id).style.visibility="visible";
	if(opacity>=99){
		zindex++;
		document.getElementById(id).style.zIndex=zindex;
		setTimeout("fade("+n+",-"+diff+","+opacity+");",2000);
		nn=(n==divs.length-1)?0:n+1;
		setTimeout("fade("+nn+","+diff+");",2000);
	} else if(opacity>0){
		setTimeout("fade("+n+","+diff+","+opacity+");",30);
	}
}
fade(0,1);
</script>
Medlem sedan feb. 2002141 inlägg
#3

Ett stort tack, Jojoxx!
Nu funkar det. Kanske borde läggas in som script på din sida? Tror många skulle uppskatta det.

Medlem sedan feb. 2002141 inlägg
#4

Upptäckte en bugg nu. Det flimrar i Firefox 1.0. Är det något som lätt går att fixa?

Medlem sedan juni 20004 308 inlägg
#5

Jepp, exemplet uppdaterat.

Medlem sedan feb. 2002141 inlägg
#6

Tusen tack! Nu funkar det.

265 ms totalt · 4 externa anrop · v20260731065814-full.1dc6f849
122 ms — deklarationer (db)
0 ms — hämta statistik (cache)
139 ms — hämta tråd, inlägg och bilagor (db)
123 ms — ändringar (db)