Weaver, Scott schrieb:
Watch out for using scripting in IE styles to fix png transparencies.  I
tried this approach and it is inefficient to say the least, especially
if your images are involved in any type of effect on the page.  I caught
IE calling the style script 3 times for a single image in some cases.
Any time you change the image in the DOM (moving, hiding, etc) the style
script will fire off.  I would highly recommend Rey's second choice of
using a pure jQuery approach, that's what I did and it works great.

hth,
-scott

In another post about fixing something else in IE with Dynamic Properties it turns out that the following works pretty fine:

img {
    behavior: expression(
        // do something to fix IE
        this.style.behavior = null
    );
}

The second line prevents that the script is called over and over again, expressions can be comma separated.

The script I wrote about to fix PNGs in IE would then look like this:

img.png {
    behavior: expression(
        this.runtimeStyle.backgroundImage = "none",
this.runtimeStyle.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + this.src + "', sizingMethod='image')",
        this.src = "/path/to/transparent.gif",
        this.style.behavior = null
    );
}

I will update the post accordingly.



-- Klaus

Reply via email to