JS文件-----------------------------------
var DD_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');
}
},
createVmlStyleSheet: function () {
var screenStyleSheet,printStyleSheet;
screenStyleSheet =document.createElement_x('style');
screenStyleSheet.setAttribute('media','screen');
document.documentElement.firstChild.insertBefore(screenStyleSheet,document.documentElement.firstChild.firstChild);
if(screenStyleSheet.styleSheet) {
screenStyleSheet= screenStyleSheet.styleSheet;
screenStyleSheet.addRule(this.ns+ '\\:*', '{behavior:url(#default#VML)}');
screenStyleSheet.addRule(this.ns+ '\\:shape', 'position:absolute;');
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('style');
printStyleSheet.setAttribute('media','print');
document.documentElement.firstChild.insertBefore(printStyleSheet,document.documentElement.firstChild.firstChild);
printStyleSheet= printStyleSheet.styleSheet;
printStyleSheet.addRule(this.ns+ '\\:*', '{display: none !important;}');
printStyleSheet.addRule('img.'+ this.ns + '_sizeFinder', '{display: none !important;}');
}
},
readPropertyChange: function () {
var el, display, v;
el = event.srcElement;
if (!el.vmlInitiated) {
return;
}
if(event.propertyName.search('background') != -1 ||event.propertyName.search('border') != -1) {
DD_belatedPNG.applyVML(el);
}
if (event.propertyName =='style.display') {
display =(el.currentStyle.display == 'none') ? 'none' : 'block';
for (v inel.vml) {
if(el.vml.hasOwnProperty(v)) {
el.vml[v].shape.style.display= display;
}
}
}
if(event.propertyName.search('filter') != -1) {
DD_belatedPNG.vmlOpacity(el);
}
},
vmlOpacity: function (el) {
if(el.currentStyle.filter.search('lpha') != -1) {
var trans =el.currentStyle.filter;
trans =parseInt(trans.substring(trans.lastIndexOf('=')+1,trans.lastIndexOf(')')), 10)/100;
el.vml.color.shape.style.filter= el.currentStyle.filter;
el.vml.image.fill.opacity= trans;
}
},
handlePseudoHover: function (el) {
setTimeout(function () {
DD_belatedPNG.applyVML(el);
}, 1);
},
fix: function (selector) {
if (this.screenStyleSheet){
varselectors, i;
selectors =selector.split(',');
for (i=0;i<selectors.length; i++) {
this.screenStyleSheet.addRule(selectors[i],'behavior:expression_r(DD_belatedPNG.fixPng(this))');
}
}
},
applyVML: function (el) {
el.runtimeStyle.cssText ='';
this.vmlFill(el);
this.vmlOffsets(el);
this.vmlOpacity(el);
if (el.isImg) {
this.copyImageBorders(el);
}
},
attachHandlers: function (el) {
var self, handlers, handler,moreForAs, a, h;
self = this;
handlers = {resize:'vmlOffsets', move: 'vmlOffsets'};
if (el.nodeName == 'A') {
moreForAs ={mouseleave: 'handlePseudoHover', mouseenter: 'handlePseudoHover',focus: 'handlePseudoHover', blur: 'handlePseudoHover'};
for (a inmoreForAs){
if(moreForAs.hasOwnProperty(a)) {
handlers[a]= moreForAs[a];
}
}
}
for (h in handlers) {
if(handlers.hasOwnProperty(h)) {
handler= function () {
self[handlers[h]](el);
};
el.attachEvent('on'+ h, handler);