CSS background images as pngs in IE can be made to work very easily. Below are the scripts I use - one is youngpups and the background script is from youngpups site somewhere but by some other guy - I have combined it with youngpups in the last example which allows both background and foreground png images:
code:
if (navigator.platform == "Win32" && navigator.appName == "Microsoft Internet Explorer" && window.attachEvent) {
window.attachEvent("onload", alphaBackgrounds);
}
function alphaBackgrounds(){
var rslt = navigator.appVersion.match(/MSIE (\d+\.\d+)/, '');
var itsAllGood = (rslt != null && Number(rslt[1]) >= 5.5);
for (i=0; i<document.all.length; i++){
var bg = document.all[i].currentStyle.backgroundImage;
if (itsAllGood && bg){
if (bg.match(/\.png/i) != null){
var mypng = bg.substring(5,bg.length-2);
document.all[i].style.filter = "progid :DXImageTransform.Microsoft.AlphaImageLoader(src='"+mypng+"', sizingMethod='scale')";
documen.all[i].style.backgroundImage = "url('images/null.gif')";
}
}
}
}
That just does background images.
Or if you use both Background images and Normal images you can do this:
code:
if (navigator.platform == "Win32" && navigator.appName == "Microsoft Internet Explorer" && window.attachEvent)
window.attachEvent("onload", pngLoadPngs);
function pngLoadPngs()
{
var rslt = navigator.appVersion.match(/MSIE (\d+\.\d+)/, '');
var itsAllGood = (rslt != null && Number(rslt[1]) >= 5.5);
if (itsAllGood){
for (var i = 0; i < document.images.length; i++){
pngLoad(document.images[i]);
}
for (i=0; i<document.all.length; i++){
var bg = document.all[i].currentStyle.backgroundImage;
if (itsAllGood && bg){
if (bg.match(/\.png/i) != null){
var mypng = bg.substring(5,bg.length-2);
document.all[i].style.filter = "progid :DXImageTransform.Microsoft.AlphaImageLoader(src='"+mypng+"', sizingMethod='scale')";
document.all[i].style.backgroundImage = "url('images/null.gif')";
}
}
}
}
}
function pngLoad(img,src)
{
if (typeof img == "object" && typeof img.tagName == "string" && img.tagName == "IMG")
{
if (typeof src == "string")
{
if (src.match(/\.png$/i) != null)
{
img.style.width = null;
img.style.height = null;
img.style.filter = null;
img.src = src;
pngSwapPrepare(img);
}
else
{
img.src = src;
}
}
else if (img.src.match(/\.png$/i) != null)
{
pngSwapPrepare(img);
}
}
function pngSwapPrepare(img)
{
if (img.complete)
pngSwap(img);
else
img.attachEvent("onload",pngOnLoadSwap);
}
function pngOnLoadSwap()
{
event.srcElement.detachEvent("onload",pngOnLoadSwap);
pngSwap(event.srcElement)
}
function pngSwap(img)
{
with (img)
{
style.width = width + "px";
style.height = height + "px";
style.filter = "progid :DXImageTransform.Microsoft.AlphaImageLoader(src='" + src + "', sizingMethod='scale') "
src = "images/null.gif";
}
}
}
<A HREF="http://www.cryokinesis.co.uk" TARGET=_blank>visit