Setting the IE opacity ;)

Discussion in 'HTML' started by Defacta, Feb 18, 2009.

  1. Defacta

    Defacta Guest

    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!
    Defacta, Feb 18, 2009
    #1
    1. Advertising

  2. Defacta <> writes:

    > http://boxfly.free.fr/test/opacity.html


    > 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.
    Eric B. Bednarz, Feb 18, 2009
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Nebojsa Dinic

    JPanel transparency (opacity)

    Nebojsa Dinic, Apr 16, 2004, in forum: Java
    Replies:
    0
    Views:
    3,323
    Nebojsa Dinic
    Apr 16, 2004
  2. DU
    Replies:
    13
    Views:
    929
  3. Sentient Fluid

    Opacity

    Sentient Fluid, Apr 22, 2005, in forum: HTML
    Replies:
    0
    Views:
    571
    Sentient Fluid
    Apr 22, 2005
  4. windandwaves

    opacity

    windandwaves, Feb 18, 2006, in forum: HTML
    Replies:
    10
    Views:
    2,284
    Jim Higson
    Feb 26, 2006
  5. Jim Higson

    What is -khtml-opacity for?

    Jim Higson, Mar 4, 2006, in forum: HTML
    Replies:
    3
    Views:
    9,721
    Toby Inkster
    Mar 5, 2006
Loading...

Share This Page