简体   繁体   English

onmouseover javascript opacity for IE8和IE7

[英]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. 它适用于FF和Safari,但不适用于IE 7或8。
Suggestions? 建议?

Ugh! 啊! CSS for the win! 获胜的CSS!

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

Lose the this.filters.alpha.opacity=30 line. this.filters.alpha.opacity=30行。 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这样的框架来帮助您规范化这样的跨浏览器不一致?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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