资源描述:
《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:v
2、ml');}},createVmlStyleSheet:function(){varscreenStyleSheet,printStyleSheet;screenStyleSheet=document_createElement_x_x('style');screenStyleSheet.setAttribute('media','screen');document.documentElement.firstChild.insertBefore(screenStyleSheet,document.d
3、ocumentElement.firstChild.firstChild);if(screenStyleSheet.styleSheet){screenStyleSheet=screenStyleSheet.styleSheet;screenStyleSheet.addRule(this.ns+'\:*','{behavior:url(#default#VML)}');screenStyleSheet.addRule(this.ns+'\:shape','position:absolute;')
4、;screenStyleSheet.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.
5、setAttribute('media','print');document.documentElement.firstChild.insertBefore(printStyleSheet,document.documentElement.firstChild.firstChild);printStyleSheet=printStyleSheet.styleSheet;printStyleSheet.addRule(this.ns+'\:*','{display:none!important;}'
6、);printStyleSheet.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.sea
9、rch('border')!=-1){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.s
10、earch('filter')!=-1){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