Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title></title>
<script type="text/javascript">
/*<![CDATA[*/
function zxcFade(id,t,ms){
var obj=document.getElementById(id),o=zxcFade['zxc'+id],f;
if (obj&&!o){
o=zxcFade['zxc'+id]={ };
}
if (o){
clearTimeout(o.dly);
f=o.now||0;
t=typeof(t)=='number'&&t>=0&&t<=100?t:0;
animate(o,obj,f,t,new Date(),(ms||1000)*Math.abs(f-t)/100+5);
}
}
function animate(o,obj,f,t,srt,mS){
var oop=this,ms=new Date().getTime()-srt,now=(t-f)/mS*ms+f;
if (isFinite(now)){
obj.style.filter='alpha(opacity='+now+')';
obj.style.opacity=obj.style.MozOpacity=obj.style.WebkitOpacity=obj.style.KhtmlOpacity=now/100-.001;
o.now=now;
}
if (ms<mS){
o.dly=setTimeout(function(){ animate(o,obj,f,t,srt,mS); },10);
}
}
/*]]>*/
</script></head>
<body onload="zxcFade('tst');">
<img id="tst" src="http://www.vicsjavascripts.org.uk/StdImages/Egypt5.jpg" alt="img" onmouseup="zxcFade('tst',0,1000)" />
<input type="button" name="" value="Fade In" onmouseup="zxcFade('tst',100,1000);"/>
<input type="button" name="" value="Fade Out" onmouseup="zxcFade('tst',0,500);"/>
</body>
</html>
Bookmarks