下面代码实现的功能是鼠标滑过图片时,图片的透明度改变。请问为什么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>
<!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>
<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>
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]
}
}