javascript - 有关于opacity兼容性,以及放在函数里面的问题
ringa_lee
ringa_lee 2017-04-11 12:17:38
0
1
474

在一本js入门经典的书中,有这样一个例子

<!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>
</head>

<body> 
<script language="javascript">
<!--
function visible(cursor,i)
{ 
if (i==0) 
    cursor.filters.alpha.opacity=100;     //问题应该出在这里//
else 
    cursor.filters.alpha.opacity=30;        //问题应该出在这里//
}
//--> 
</script>
<table border="0" cellpadding="0" cellspacing="0"> 
  <tr> 
    <td align="center" bgcolor="#CCCCCC">
      <img src="Temp.jpg" border="0" style="filter:alpha(opacity=100)" onMouseOver="visible(this,1)" onMouseOut="visible(this,0)" width="148" height="121">
    </td> 
  </tr> 
</table> 
</body>
</html>

试过各种改,但是图片还是不能动,应该是兼容性问题,但是网上找了好多答案都只是给
出大致这样opacity: .5;filter:alpha(opacity=50); 的方案,下面是我改过的,但还是不行

<!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>
</head>

<body> 
<script language="javascript">
<!--
function visible(cursor,i)
{ 
if (i==0) 
    cursor.opacity=0.5;
    // console.log("out"); 
else 
    cursor.opacity=0.3;
    // console.log(into); 
}
//--> 
</script>
<table border="0" cellpadding="0" cellspacing="0"> 
  <tr> 
    <td align="center" bgcolor="#CCCCCC">
      <img src="Temp.jpg" border="0" style="opacity:0.5" onMouseOver="visible(this,1)" onMouseOut="visible(this,0)" width="148" height="121">
    </td> 
  </tr> 
</table> 
</body>
</html>

(这里忽略ie浏览器)
求解答,不然睡不着啊

ringa_lee
ringa_lee

ringa_lee

reply all(1)
Ty80

cursor.opacity => cursor.style.opacity

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!