请选择 进入手机版 | 继续访问电脑版
搜索
发新帖

7314

积分

好友

主题
发表于 2011-10-11 13:14:49 | 查看: 4201| 回复: 1

  1. <!--[if IE 6]>
  2. <script>
  3. function correctPNG()
  4. {
  5. for(var i=0; i<document.images.length; i++)
  6. {
  7. var img = document.images[i];
  8. var imgName = img.src.toUpperCase();
  9. if (imgName.substring(imgName.length-3, imgName.length) == "PNG")
  10. {
  11. var imgID = (img.id) ? "id='" + img.id + "' " : "";
  12. var imgClass = (img.className) ? "class='" + img.className + "' " : "";
  13. var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' ";
  14. var imgStyle = "display:inline-block;" + img.style.cssText;
  15. if (img.align == "left") imgStyle = "float:left;" + imgStyle;
  16. if (img.align == "right") imgStyle = "float:right;" + imgStyle;
  17. if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle;
  18. var strNewHTML = "<span "+ imgID + imgClass + imgTitle + "style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
  19. + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader" + "(src='" + img.src + "', sizingMethod='scale');\"></span>";
  20. img.outerHTML = strNewHTML;
  21. i = i-1;
  22. }
  23. }
  24. }
  25. window.attachEvent("onload", correctPNG);
  26. </script>
  27. <![endif]-->
复制代码
把代码 加到 页头文件 任何地方 就可以解决PNG图片在 IE6 浏览器里不透明的问题。
发表于 2011-10-23 13:44:15
以下方法试验有效:
  1. <!--[if IE 6]>
  2. <script>
  3. function correctPNG()
  4. {
  5. for(var i=0; i<document.images.length; i++)
  6. {
  7. var img = document.images[i];
  8. var imgName = img.src.toUpperCase();
  9. if (imgName.substring(imgName.length-3, imgName.length) == "PNG")
  10. {
  11. var imgID = (img.id) ? "id='" + img.id + "' " : "";
  12. var imgClass = (img.className) ? "class='" + img.className + "' " : "";
  13. var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' ";
  14. var imgStyle = "display:inline-block;" + img.style.cssText;
  15. if (img.align == "left") imgStyle = "float:left;" + imgStyle;
  16. if (img.align == "right") imgStyle = "float:right;" + imgStyle;
  17. if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle;
  18. var strNewHTML = "<span "+ imgID + imgClass + imgTitle + "style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
  19. + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader" + "(src='" + img.src + "', sizingMethod='scale');\"></span>";
  20. img.outerHTML = strNewHTML;
  21. i = i-1;
  22. }
  23. }
  24. }
  25. window.attachEvent("onload", correctPNG);
  26. </script>
  27. <![endif]-->
复制代码

回复 显示全部楼层 道具 举报

您需要登录后才可以回帖 登录 | 立即注册

推荐文章

广告推广

( 粤ICP备12033978号 )
快速回复 返回顶部 返回列表