站长论坛

标题: 鼠标感应渐显图片 [打印本页]

作者: webptr    时间: 2007-10-6 09:17
标题: 鼠标感应渐显图片
<html>
<head>
<title></title>
<script language="javascript">
var min=10;
var max=100;
var number=1;
function OnMouseOver(obj)
{
  if(obj.changing)
    clearInterval(obj.changing);
  obj.changing=setInterval("add("+obj.id+")",10);
}
function OnMouseOut(obj)
{
  if(obj.changing)
    clearInterval(obj.changing);
  obj.changing=setInterval("sub("+obj.id+")",10);
}
function add(obj)
{
  if(obj.filters.Alpha.Opacity > max)
  {
    clearInterval(obj.changing);
    obj.changing=false;
    obj.filters.Alpha.Opacity = max;
  }
  else
    obj.filters.Alpha.Opacity += number;
  test1.innerText = "img1:"+img1.filters.Alpha.Opacity;
  test2.innerText = "img2:"+img2.filters.Alpha.Opacity;
}
function sub(obj)
{
  if(obj.filters.Alpha.Opacity < min)
  {
    clearInterval(obj.changing);
    obj.changing=false;
    obj.filters.Alpha.Opacity = min;
  }
  else
    obj.filters.Alpha.Opacity += -number;
  test1.innerText = "img1:"+img1.filters.Alpha.Opacity;
  test2.innerText = "img2:"+img2.filters.Alpha.Opacity;
}
</script>
</head>
<body>
<img id='img1' src="http://be10.ods.org/51js/images/standard/51js.gif" style="filter:Alpha(Opacity=10)" onmouseover="OnMouseOver(this)" onmouseout="OnMouseOut(this)">
<img id='img2' src="http://be10.ods.org/51js/images/standard/51js.gif" style="filter:Alpha(Opacity=10)" onmouseover="OnMouseOver(this)" onmouseout="OnMouseOut(this)">
<div id='test1'>img1:10</div>
<div id='test2'>img2:10</div>
</body>
</html>




欢迎光临 站长论坛 (http://www.tzlink.com/bbs/) Powered by Discuz! X3.2