知觅朱高,今天
关于我
今天
关于今天
交流选
旧的回忆
留言簿
前一天:第176天:关于“感谢分享”要不要显示友吧内部成员的投票
后一天:第178天:举报者与被举报者,Blog 使用 google 自定义搜索

第177天:用于IE6下png图片透明的js,UCenter Home 1.5正式版即将发布


星期四 晴 11~17℃

用于 IE6 下 png 图片透明的 js

网上流传了几种方法,以下是其中一种,使直接插入到页面中的所有 png 图片在 IE6 下透明有效,但是对 png 背景图无效。(2009-1-15 更新:用于IE6下png背景透明的js

<script language="JavaScript">
function correctPNG() // correctly handle PNG transparency in Win IE 5.5 & 6.
{
    var arVersion = navigator.appVersion.split("MSIE")
    var version = parseFloat(arVersion[1])
    if ((version < 7.0) && (document.body.filters))
    {
       for(var j=0; j<document.images.length; j++)
       {
          var img = document.images[j]
          var imgName = img.src.toUpperCase()
          if (imgName.substring(imgName.length-3, imgName.length) == "PNG")
          {
             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.align == "left") imgStyle = "float:left;" + imgStyle
             if (img.align == "right") imgStyle = "float:right;" + imgStyle
             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='image');\"></span>"
             img.outerHTML = strNewHTML
             j = j-1
          }
       }
    }    
}
window.attachEvent("onload", correctPNG);
</script>

2011-04-28 更新:

  1. 原来的代码,sizingMethod='scale',经测试在 ie6 下会产生字体模糊,改为 sizingMethod='image'
  2. 原来的条件为 version >= 5.5,现在改为 version < 7.0
  3. 如果只是个别图片需要用到透明,那么可以直接把这段代码加最后一张透明图片下方,并把 window.attachEvent("onload", correctPNG) 改为 correctPNG(); 这样在 ie6 页面加载过程不会看到图片的透明部份是灰底。

UCenter Home 1.5正式版即将发布

昨晚在论坛上看到公告,官方网站在 5 天前已经开始使用 UCenter Home 1.5正式版,离正式发布提供下载的日子想必不远了。

我们也一直在等正式版,以免因为不能等这两三个月的时间而使将来后悔。大概等正式版出来,我们的 Home 首页也设计得差不多了,正好可以直接套进去上线测试。

附:

UCenter Home 1.5 RC2 提供下载:2008-9-10
UCenter Home 1.2 正式版提供下载:2008-5-22
UCenter Home 1.0 正式版提供下载:2008-4-21


The Farmer and the Snake
from http://classics.mit.edu/Aesop/fab.1.1.html#183

One winter a Farmer found a Snake stiff and frozen with cold. He had compassion on it, and taking it up, placed it in his bosom. The Snake was quickly revived by the warmth, and resuming its natural instincts, bit its benefactor, inflicting on him a mortal wound. "Oh," cried the Farmer with his last breath, "I am rightly served for pitying a scoundrel."

The greatest kindness will not bind the ungrateful.

农夫与蛇的故事:对恶人不要有仁慈之心。

前一天:第176天:关于“感谢分享”要不要显示友吧内部成员的投票
后一天:第178天:举报者与被举报者,Blog 使用 google 自定义搜索

对当前日志的留言

发表评论

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。

最新评论

最新日志

知觅朱高,今天
知觅朱高,今天