先附上报错的代码:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>动态改变图片的焦点</title>
</head>
<body>
<script type="text/javascript">
function visible(cursor,i) {
if(i==0)
cursor.filters.alpha.opacity=100;
else
cursor.filters.alpha.opacity=50;
}
</script>
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td align="center">
<img src="images/3.jpg" border="0" style="filter:alpha(opacity=100)" onMouseOver="visible(this,1)" onMouseOut="visible(this,0)" width="148" HEIGHT="148">
</td>
</tr>
</table>
</body>
</html>
然后调试的时候就出现了这样的错误:
alpha
没有定义。
这样解决:
把代码中的:
cursor.filters.alpha.opacity=100;
改为:
cursor.style.opacity=1;
完美解决问题。