图片的淡入淡出的实现方法

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>无标题文档</title>
</head>
<body>
<script language="javascript">
var timer=null;
function fade(obj,which)
{
clearTimeout(timer);
if (which==0)
{
    if (obj.filters.alpha.opacity!=100)
       obj.filters.alpha.opacity+=10;   
}
else
{
if (obj.filters.alpha.opacity!=30)
    obj.filters.alpha.opacity-=10;  
}

if ((obj.filters.alpha.opacity!=100)&&(obj.filters.alpha.opacity!=30))
timer=setTimeout("fade("+obj.id+","+which+")",100);
}

</script>
<img id="a3" src='http://img1.qq.com/news/pics/1146/1146261.jpg' style="filter:alpha(opacity=30)" onMouseOver=fade(this,0) onMouseOut=fade(this,1)>
</body>
</html>
 

posted @ 2008-03-04 15:25  attitudedecidesall  Views(266)  Comments(0Edit  收藏  举报