开发者

onmouseover javascript opacity for IE8 and IE7

开发者 https://www.devze.com 2022-12-16 19:56 出处:网络
This is what I have so far: <img src=\"images/test.jpg\" class=\"black\" onmouseout=\"this.style.opacity=1;

This is what I have so far:

<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='p开发者_高级运维rogid:DXImageTransform.Microsoft.Alpha(Opacity=30)'" 
/>

It's works in FF and Safari, but not IE 7 or 8.

Suggestions?


Ugh! CSS for the win!

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


Lose the this.filters.alpha.opacity=30 line. Corrected code:

<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)'"  
/> 


Have you considered using a framework like YUI or JQuery to help you normalize cross-browser inconsistencies like this?

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号