IE6下图片滤镜

// 修复 IE 下 PNG 图片不能透明显示的问题
function fixPNG(myImage)
{
    var arVersion = navigator.appVersion.split("MSIE");
    var version = parseFloat(arVersion[1]);
        
    if (Sys.Browser.agent == Sys.Browser.InternetExplorer && (version >= 5.5) && (version < 7) && (document.body.filters))
    {
        var imgID = (myImage.id) ? "id='" + myImage.id + "' " : "";
        var imgClass = (myImage.className) ? "class='" + myImage.className + "' " : "";
        var imgTitle = (myImage.title) ? "title='" + myImage.title  + "' " : "title='" + myImage.alt + "' ";
        var imgStyle = "display:inline-block;" + myImage.style.cssText + "; ";
        if (myImage.width > 200) {
            imgStyle += "vertical-align:middle; margin-left:25px;margin-top:0px";
        }else{
            imgStyle += "vertical-align:middle; margin-left:0px;margin-top:0px";
        }
        var strNewHTML = "<span " + imgID + imgClass + imgTitle

       + " style=\"" + "width:" + myImage.width

       + "px; height:" + myImage.height

       + "px;" + imgStyle + ";"

       + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"

       + "(src=\'" + myImage.src + "\', sizingMethod='scale');\"></span>";
        myImage.outerHTML = strNewHTML;
    }

posted @ 2010-04-27 15:24  Jake.Xu  阅读(436)  评论(0编辑  收藏  举报