下面代码实现的功能是鼠标滑过图片时,图片的透明度改变。请问为什么IE浏览器中运行正常,而在谷歌中没有变化,如何改呢?谢谢!代码如下:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>改变图片获取焦点时的状态</title><script type="text/javascript"> 
function visible(cursor,i)

if (i==0) 
cursor.filters.alpha.opacity=100; 
else 
cursor.filters.alpha.opacity=30;

</script></head><body> 
<table border="0" cellpadding="0" cellspacing="0"> 
  <tr> 
    <td align="center" bgcolor="#CCCCCC">
<a class="link_image" href="http://www.mingrisoft.com">
<img src="Temp.jpg" alt="test" title="haha" border="0" style="filter:alpha(opacity=100)" onmouseover="visible(this,1)" onmouseout="visible(this,0)" width="148" height="121">
</a> 
</td> 
  </tr> 
</table> 
</body></html>

解决方案 »

  1.   

    首先你得明白,非IE css的透明代码是style="opacity:0.3"那就好办了。<img src="http://image.uctrac.com/20121108/10/e9270238-1f11-4e34-81e1-fe4fa2431239.jpg" alt="test" title="haha" border="0" style="filter:alpha(opacity=100);opacity:1" onmouseover="visible(this,1)" onmouseout="visible(this,0)" width="148" height="121">
    <script type="text/javascript">
     function visible(cursor,i){
        var n=i>0?30:100;
        if (-[1,]){
            cursor.style.opacity=n/100;
        }else{
            cursor.filters.alpha.opacity=n;
        }
     }
    </script>
      

  2.   

     function visible(cursor,i){
        var n=i>0?30:100;//判断透明度值
        if (-[1,]){
    //非IE浏览器
            cursor.style.opacity=n/100;//透明度使用opacity 值的范围[0-1]
        }else{
    //IE浏览器
            cursor.filters.alpha.opacity=n;//透明度使用filters.alpha.opacity 值的范围[0-100]
        }
     }
      

  3.   

    filters 是IE only 楼主搜索下 js 多浏览器兼容