简体   繁体   中英

onmouseover javascript opacity for IE8 and IE7

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM