2010-01-13 97 views
1

的onmouseover JavaScript的不透明度這是我到目前爲止有:爲IE8和IE7

<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
建議?

回答

0

你有沒有考慮過使用像YUI或JQuery這樣的框架來幫助你規範這種跨瀏覽器的不一致?

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