pnoeric
asked on
Swap PNGs using JavaScript - with IE6 PNG hack!
Hi, I have a div with a transparent PNGs background. To make this work in IE6,I'm using the Microsoft filter:progID hack, and that is fine.
Here's my CSS code:
#element {
background: url(/images/old.png) no-repeat;
}
/* this next part is only parsed by IE6 */
* html #element {
background-image: none;
filter: progid:DXImageTransform.Mi crosoft.Al phaImageLo ader(src=" /images/ol d.png", sizingMethod="crop");
}
And again, that code all works perfectly.
I now need to have Javascript change the div's background PNG on the fly. (I'm using script.aculo.us to make it a little easier.)
Doing this in Firefox is no problem... I just do a simple:
$('element').style.backgro und= 'url(/images/new.png)';
However, how can I do this with IE6? I tried:
$('element').style.filter= 'progid:DX ImageTrans form.Micro soft.Alpha ImageLoade r(src="/im ages/new.p ng", sizingMethod="crop")';
With no luck. Ugh.
Any advice welcome--
thx,
Eric
Here's my CSS code:
#element {
background: url(/images/old.png) no-repeat;
}
/* this next part is only parsed by IE6 */
* html #element {
background-image: none;
filter: progid:DXImageTransform.Mi
}
And again, that code all works perfectly.
I now need to have Javascript change the div's background PNG on the fly. (I'm using script.aculo.us to make it a little easier.)
Doing this in Firefox is no problem... I just do a simple:
$('element').style.backgro
However, how can I do this with IE6? I tried:
$('element').style.filter=
With no luck. Ugh.
Any advice welcome--
thx,
Eric
to apply filters to elements in IE you need the element to have 'layout' i.e. it needs to have a width or height specified.
if you don't know the dimensions beforehand then just try adding height:1% to the element's CSS.
ref: http://jszen.blogspot.com/2005/04/ie6-opacity-filter-caveat.html
if you don't know the dimensions beforehand then just try adding height:1% to the element's CSS.
ref: http://jszen.blogspot.com/2005/04/ie6-opacity-filter-caveat.html
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
mreuring, that was it exactly-- thank you.
ASKER