布丁足迹

千里始足下,高山起微尘,吾道亦如此,行之贵日新。

解决 ie6 png 图片背景透明问题

方法一、通过 css 和 IE 专有属性 behavior 解决整站 png 背景透明问题

<style type="text/css">
<!--
img { behavior:url(/iepngfix.htc); }
-->
</style>

htc文件内容

<public:component>
<public:attach event="onpropertychange" onevent="doFix()" />
<script type="text/javascript">
// IE5.5+ PNG Alpha Fix v1.0RC3
// (c) 2004-2005 Angus Turnbull http://www.twinhelix.com
// This is licensed under the CC-GNU LGPL, version 2.1 or later.
// For details, see: http://creativecommons.org/licenses/LGPL/2.1/
// This must be a path to a blank image. That's all the configuration you need.
var blankImg = '/spacer.gif';
var f = 'DXImageTransform.Microsoft.AlphaImageLoader';
function filt(s,m)
 {
 if (filters[f])
  {
    filters[f].enabled = s ? true : false;
    if (s) with (filters[f])
   {
   src = s;
   sizingMethod = m;
   }
   }
  else if (s)
  {
  style.filter = 'progid:'+f+'(src="'+s+'",sizingMethod="'+m+'")';
  }
 }
function doFix()
 {
 // Assume IE7 is OK
 if (!/MSIE (5\.5|6\.)/.test(navigator.userAgent) || (event && !/(background|src)/.test(event.propertyName)))
  {
  return;
  }
 var bgImg = currentStyle.backgroundImage || style.backgroundImage;
 if (tagName == 'IMG')
  {
  if ((/\.png$/i).test(src))
   {
   // this tests to see if the image has already been replaced once before
   if (src.indexOf('?repurl=') == -1)
    {
    if (currentStyle.width == 'auto' && currentStyle.height == 'auto')
        {
     style.width = offsetWidth+'px';
     }
    filt(src,'scale');
    src = blankImg+'?repurl='+src;
    }
   }
  else if (src.indexOf(blankImg) < 0)
   {
   filt();
   }
  }
 else if (bgImg && bgImg != 'none')
  {
    if (bgImg.match(/^url[("']+(.*\.png)[)"']+$/i))
     {
     var s = RegExp.$1;
     if (currentStyle.width == 'auto' && currentStyle.height == 'auto')
       {
    style.width = offsetWidth+'px';
    }
     style.backgroundImage = 'none';
     filt(s,'crop');
     // IE link fix
     for (var n=0;n<childNodes.length;n++)
    {
    if (childNodes[n].style) { childNodes[n].style.position = 'relative'};
    }
     }
  else filt();
  }
 }
doFix();
</script>
</public:component>

 

更多
« 55种网页常用小技巧自动换行word-break:break-all和word-wrap:break-word的区别 »
  • 相关文章:

发表评论:

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

黄金广告位求包养

最会抢沙发的淫

宣传推广栏

完全随机文章

最新评论及回复

最近留言

Powered By Z-Blog 1.8 Walle Build 100427

[过度上网,有害健康]    感谢诚网科技提供空间
版权所有 © 2007-2010 布丁足迹 辽ICP备08100443号

你敢来踩,我就敢回踹