onmouseover javascript opacity for IE8和IE7

时间:2010-01-13 16:48:46

标签: javascript transparency inline

这是我到目前为止所做的:

<img src="images/test.jpg" 
class="black" 

onmouseout="this.style.opacity=1;
this.filters.alpha.opacity=100;
this.style.filter='progid:DXImageTransform.Microsoft.Alpha(Opacity=100)"

onmouseover="this.style.opacity=0.3;
this.filters.alpha.opacity=30;
this.style.filter='progid:DXImageTransform.Microsoft.Alpha(Opacity=30)'" 
/>

它适用于FF和Safari,但不适用于IE 7或8 建议?

3 个答案:

答案 0 :(得分:2)

唉!获胜的CSS!

<style>
img.black:hover {opacity: 0.3; filter:alpha(opacity=30);}
</style>

答案 1 :(得分:2)

丢失this.filters.alpha.opacity=30行。更正后的代码:

<img src="images/test.jpg" class="black"  
    onmouseout="this.style.opacity=1; 
      this.style.filter='progid:DXImageTransform.Microsoft.Alpha(Opacity=100)'" 

    onmouseover="this.style.opacity=0.3
      this.style.filter='progid:DXImageTransform.Microsoft.Alpha(Opacity=30)'"  
/> 

答案 2 :(得分:0)

你是否考虑使用像YUI或JQuery这样的框架来帮助你规范化这样的跨浏览器不一致?