这个方法开发项目的时候一直在用,简单的两步就可以使用了。
首先在
与之间加入下面的代码:
其中png.js的完整代码如下:
/**
* DD_belatedPNG: Adds IE6 support: PNG images for CSS background-image and HTML
.
* Author: Drew Diller
* Example usage:
* DD_belatedPNG.fix(.png_bg); / argument is a CSS selector
* DD_belatedPNG.fixPng( someNode ); / argument is an HTMLDomElement
**/
eval(function(p,a,c,k,e,r){e=function(c){return(c35?String.fromCharCode(c+29):c.toString(36))};if(!.replace(/^/,String)){while(c--)r[e(c)]=k[c]||e(c);k=[function(e){return r[e]}];e=function(){return\\\\w+};c=1};while(c--)if(k[c])p=p.replace(new RegExp(\\\\b+e(c)+\\\\b,g),k[c]);return p}(2 E={J:\\E\\,Z:{},1E:7(){4(x.1l&&!x.1l[6.J]){x.1l.23(6.J,\\24:25-26-27:3\\)}4(1F.11){1F.11(\\28\\,7(){E=29})}},1G:7(){2 a=x.1m(\\8\\);x.1H.1b.1n(a,x.1H.1b.1b);2 b=a.1o;b.1c(6.J+\\\\\\\\\\:*\\,\\{12:2a(#1I#2b)}\\);b.1c(6.J+\\\\\\\\\\:9\\,\\Q:1p;\\);b.1c(\\1J.\\+6.J+\\1K\\,\\12:y; 1q:y; Q:1p; z-2c:-1; 1d:-1r; 1L:1M;\\);6.1o=b},1N:7(){2 a=13.2d;4(13.1e.K(\\2e\\)!=-1||13.1e.K(\\1q\\)!=-1){E.1f(a)}4(13.1e==\\8.1s\\){2 b=(a.F.1s==\\y\\)?\\y\\:\\2f\\;G(2 v M a.3){a.3[v].9.8.1s=b}}4(13.1e.K(\\14\\)!=-1){E.1t(a)}},1t:7(a){4(a.F.14.K(\\2g\\)!=-1){2 b=a.F.14;b=1u(b.2h(b.1v(\\=\\)+1,b.1v(\\)\\)),10)/2i;a.3.N.9.8.14=a.F.14;a.3.C.I.2j=b}},15:7(a){2k(7(){E.1f(a)},1)},2l:7(a){2 b=a.1O(\\,\\);G(2 i=0;ig.H){c.B=g.H}e.3.C.9.8.1Z=\\20(\\+c.T+\\u \\+(c.R+i)+\\u \\+c.B+\\u \\+(c.L+i)+\\u)\\}U{e.3.C.9.8.1Z=\\20(\\+p.T+\\u \\+p.R+\\u \\+p.B+\\u \\+p.L+\\u)\\}},1P:7(a){a.8.12=\\y\\;4(a.17==\\32\\||a.17==\\33\\||a.17==\\34\\){1g}a.O=V;4(a.17==\\35\\){4(a.1h.21().K(/\\\\.22$/)!=-1){a.O=P;a.8.1L=\\1M\\}U{1g}}U 4(a.F.19.21().K(\\.22\\)==-1){1g}2 b=E;a.3={N:{},C:{}};2 c={9:{},I:{}};G(2 r M a.3){G(2 e M c){2 d=b.J+\\:\\+e;a.3[r][e]=x.1m(d)}a.3[r].9.36=V;a.3[r].9.37(a.3[r].I);a.38.1n(a.3[r].9,a)}a.3.C.9.39=\\y\\;a.3.C.I.3a=\\3b\\;a.3.N.I.1w=V;b.1T(a);b.1x(a);b.1x(a.3c);b.1f(a)}};3d{x.3e(3f,V,P)}3g(r){}E.1E();E.1G();,62,203,||var|vml|if||this|function|style|shape|||||||||||||||||||||px|||document|none||||image|vmlBg|DD_belatedPNG|currentStyle|for||fill|ns|search||in|color|isImg|true|position||runtimeStyle||else|false||||imgSize||attachEvent|behavior|event|filter|handlePseudoHover|vmlOffsets|nodeName|backgroundColor|backgroundImage|case|firstChild|addRule|top|propertyName|applyVML|return|src|width|height|bLW|namespaces|createElement|insertBefore|styleSheet|absolute|border|10000px|display|vmlOpacity|parseInt|lastIndexOf|on|giveLayout|left|bTW|break|b1|b2|repeat|createVmlNameSpace|window|createVmlStyleSheet|documentElement|default|img|_sizeFinder|visibility|hidden|readPropertyChange|split|fixPng|cssText|vmlFill|copyImageBorders|attachHandlers|zIndex|transparent|removeAttribute|body|0l|clip|rect|toLowerCase|png|add|urn|schemas|microsoft|com|onbeforeunload|null|url|VML|index|srcElement|background|block|lpha|substring|100|opacity|setTimeout|fix|length|expression|resize|move|mouseleave|mouseenter|focus|blur|onpropertychange|zoom|static|relative|borderStyle|borderWidth|borderColor|substr|className|onload|offsetWidth|offsetHeight|clientWidth|clientHeight|offsetLeft|offsetTop|clientLeft|clientTop|coordsize|coordorigin|path|m0|l0|xe|switch|center|right|bottom|01|Math|ceil|backgroundPosition|backgroundRepeat|toUpperCase|BODY|TD|TR|IMG|stroked|appendChild|parentNode|fillcolor|type|tile|offsetParent|try|execCommand|BackgroundImageCache|catch.split(|),0,{}))
然后在需要使PNG透明的html代码中调用下面的代码:
class=png_bg