修复在IE6下img标签引用半透明png图片的bug

<!--[if lte ie 6]>
<script type="text/javascript">
    function correctPNG() {
        var images = document.getElementsByTagName('IMG');
        for (var i = 0, len = images.length; i < len; i++) {
            var img = images[i];
            if (img.className && img.className.indexOf('alpha-opacity') !== -1) {
                var imgID = (img.id) ? "id='" + img.id + "' " : "";
                var imgClass = (img.className) ? "class='" + img.className + "' " : "";
                var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' ";
                var imgStyle = "display:inline-block;" + img.style.cssText;
                if (img.parentElement.href) {
                    imgStyle = "cursor:hand; " + imgStyle;
                }
                var strNewHTML = "<span " + imgID + imgClass + imgTitle
                        + " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle
                        + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
                        + "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>";
                img.outerHTML = strNewHTML;
                --i;
                --len;
            }
        }
    }
    window.attachEvent("onload", correctPNG);
</script>
<![endif]-->

修复在IE6下img标签引用半透明png图片的bug》上有1条评论

发表评论