Setting the IE opacity ;)

D

Defacta

HiYa!

I am trying to set the opacity of a div, it works with FF and with
Safari but not with IE7:
The page (which has been reduced) is:
http://boxfly.free.fr/test/opacity.html

Using IE7, we enter inside the "if" of the function:

function change_opa(i) {
if(document.all) {
alert("dans if") ;
document.getElementById('main-data').style.filter='alpha
(opacity=30)';
} else {
alert("dans else") ;
document.getElementById('main-data').style.opacity = 3/10 ;
}

}

But IE7 does not do the .style.filter...

Any idea ?

Thanks,
Vincent.

PS: Sorry for the alert('') which takes all the page!
 
E

Eric B. Bednarz

Defacta said:
function change_opa(i) {
if(document.all) {

This is no good test at all. Use JScript’s conditional compilation or
conditional comments in your HTML.
But IE7 does not do the .style.filter...

The div element doesn’t have layout.

MSDN on filters:
“[…] the object that the filter is applied to must have layout before
the filter effect will display […]â€
<http://msdn.microsoft.com/en-us/library/ms532847(VS.85).aspx>

MSDN on hasLayout:
<http://msdn.microsoft.com/en-us/library/ms533776.aspx>

zoom: 1;

has the least side effects.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,481
Members
44,900
Latest member
Nell636132

Latest Threads

Top