zoukankan      html  css  js  c++  java
  • 解决ie6下png的透明背景问题

    /*----解决ie6下png的透明背景问题----*/
            var clear="Content/Images/clear.gif"; //path to clear.gif
            document.write('<script type="text/javascript" id="ct" defer="defer" src="javascript:void(0)"><\/script>');
            var ct=document.getElementById("ct");
            ct.onreadystatechange=function(){pngfix()};
            pngfix=function(){
                var els=document.getElementsByTagName('*'),ip=/\.png/i,al="progid:DXImageTransform.Microsoft.AlphaImageLoader(src='",i=els.length,uels=new Array(),c=0;
                while(i-->0){
                    if(els[i].className.match(/unitPng/))
                    {
                        uels[c]=els[i];c++;
                     }
                 }
                 if(uels.length==0){
                    pfx(els);
                 } else{
                    pfx(uels);
                 }
                 function pfx(els){
                    i=els.length;
                    while(i-->0){
                        var el=els[i],es=el.style,elc=el.currentStyle,elb=elc.backgroundImage;
                        if(el.src&&el.src.match(ip)&&!es.filter){
                            es.height=el.height;es.width=el.width;es.filter=al+el.src+"',sizingMethod='crop')";
                            el.src=clear;
                        }else{
                            if(elb.match(ip)){
                                var path=elb.split('"'),rep=(elc.backgroundRepeat=='no-repeat')?'crop':'scale',elkids=el.getElementsByTagName('*'),j=elkids.length;es.filter=al+path[1]+"',sizingMethod='"+rep+"')";
                                es.height=el.clientHeight+'px';es.backgroundImage='none';
                                if(j!=0){
                                    if(elc.position!="absolute")es.position='static';
                                    while(j-->0)
                                        if(!elkids[j].style.position)elkids[j].style.position="relative";
                                    }
                                }
                            }
                        }
                 };
              };
               /*----解决ie6下png的透明背景问题----*/
  • 相关阅读:
    AutoCAD.NET 二次开发(一) 自定义菜单及自动加载
    WSS 3.0部署备忘 一
    WSS 3.0部署备忘 四
    WSS 3.0部署备忘 三
    WSS 3.0部署备忘 二
    loj_1042
    loj_1045
    vim的学习笔记(3)
    Linux的磁盘与文件管理系统(1)
    文件与文件系统的压缩与打包
  • 原文地址:https://www.cnblogs.com/xcsn/p/3062358.html
Copyright © 2011-2022 走看看