资源描述:
《ie6 png图片透明的问题—js解决》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、一:先保存以下js代码:(DD_belatedPNG_0.0.8a.js)varDD_belatedPNG={ns:'DD_belatedPNG',imgSize:{},delay:10,nodesFixed:0,createVmlNameSpace:function(){if(document.namespaces&&!document.namespaces[this.ns]){document.namespaces.add(this.ns,'urn:schemas-microsoft-com:vml'
2、);}},createVmlStyleSheet:function(){varscreenStyleSheet,printStyleSheet;screenStyleSheet=document_createElement_x_x('style');screenStyleSheet.setAttribute('media','screen');document.documentElement.firstChild.insertBefore(screenStyleSheet,document.documen
3、tElement.firstChild.firstChild);if(screenStyleSheet.styleSheet){screenStyleSheet=screenStyleSheet.styleSheet;screenStyleSheet.addRule(this.ns+'\:*','{behavior:url(#default#VML)}');screenStyleSheet.addRule(this.ns+'\:shape','position:absolute;');screenSt
4、yleSheet.addRule('img.'+this.ns+'_sizeFinder','behavior:none;border:none;position:absolute;z-index:-1;top:-10000px;visibility:hidden;');this.screenStyleSheet=screenStyleSheet;printStyleSheet=document_createElement_x_x('style');printStyleSheet.setAttribute
5、('media','print');document.documentElement.firstChild.insertBefore(printStyleSheet,document.documentElement.firstChild.firstChild);printStyleSheet=printStyleSheet.styleSheet;printStyleSheet.addRule(this.ns+'\:*','{display:none!important;}');printStyleShe
6、et.addRule('img.'+this.ns+'_sizeFinder','{display:none!important;}');}},readPropertyChange:function(){varel,display,v;el=event.srcElement;if(!el.vmlInitiated){return;}if(event.propertyName.search('background')!=-1
7、
8、event.propertyName.search('border')!=-1)
9、{DD_belatedPNG.applyVML(el);}if(event.propertyName=='style.display'){display=(el.currentStyle.display=='none')?'none':'block';for(vinel.vml){if(el.vml.hasOwnProperty(v)){el.vml[v].shape.style.display=display;}}}if(event.propertyName.search('filter')!=-1){
10、DD_belatedPNG.vmlOpacity(el);}},vmlOpacity:function(el){if(el.currentStyle.filter.search('lpha')!=-1){vartrans=el.currentStyle.filter;trans=parseInt(trans.substring(trans.lastIndexOf('=')+1,trans.lastIndexOf(')')),1