[Beschreibung]
Fading- Effekte bei Image- Links
Beachten Sie bitte, dass die Positionierung der Elemente via Style Sheets realisiert wird.
[Kompatibilität]
[Code]
<style type="text/css"> #content {position:relative;width:200px;visibility:hidden;} #img1 {position:absolute;width:200px;height:40px;left:0px;top:0px;filter:alpha(opacity=100);-moz-opacity:100%;} #lyr1 {position:absolute;width:200px;height:40px;left:0px;top:0px;} #img2 {position:absolute;width:200px;height:40px;left:0px;top:60px;filter:alpha(opacity=100);-moz-opacity:100%;} #lyr2 {position:absolute;width:200px;height:40px;left:0px;top:60px;} #img3 {position:absolute;width:200px;height:40px;left:0px;top:120px;filter:alpha(opacity=100);-moz-opacity:100%;} #lyr3 {position:absolute;width:200px;height:40px;left:0px;top:120px;} </style>
<script language="Javascript1.2" type="text/javascript"> /************************************************************************ Script made by Martial Boissonneault © 2001-02 http://getElementById.com/ This script may be used and changed freely as long as this msg is intact Visit http://getElementById.com/ for more free scripts and tutorials. *************************************************************************/ var ie5=(document.all && document.getElementById); var ns6=(!document.all && document.getElementById);
nOpac = 100 nPlus = 7 speed = 50 timer = null;
function fadeImg(num){ opacity = nOpac+nPlus; nOpac = opacity; timer = setTimeout('fadeImg("'+num+'")',speed); if(opacity>100){
nPlus=-nPlus; } if(ie5){
obj[num].style.filter="alpha(opacity="+opacity+")"; } if(ns6){
obj[num].style.MozOpacity = opacity + '%'; } }
function restore(num){ clearTimeout(timer); if(ns6) obj[num].style.MozOpacity = '100%'; if(ie5) obj[num].style.filter="alpha(opacity=100)"; nOpac = 100; }
function fadingRollover(){ if(ie5 || ns6){
obj = document.getElementById("content").getElementsByTagName("img");
div = document.getElementById("content");
div.style.visibility = "visible"; } } onload=fadingRollover; </script>
<div id="lyr2"><img src="over2.gif" border=0 width=200 height=40></div> <a href="#" onmouseover="fadeImg('img2');" onmouseout="restore('img2');"> <img src="out2.gif" id="img2" border=0 width=200 height=40></a>
<div id="lyr3"><img src="over3.gif" border=0 width=200 height=40></div> <a href="#" onmouseover="fadeImg('img3');" onmouseout="restore('img3');"> <img src="out3.gif" id="img3" border=0 width=200 height=40></a> </div>
GetElementById
Kopieren Sie bitte den Code