1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
| $(savePNG)
function savePNG(){
if(!jQuery.browser.msie)return
rePng = /\.png/gi
reUrl = /url\((.+)\)/
imgBlank = 'space.gif';
$('*',$('body')).each(
function (i){
// 1 Traitement des attributs background
if($(this).attr('background')){
var bg = $(this).attr('background')
if(bg.match(rePng)!=null){
$(this).attr('background','')
$(this).css('backgroundImage','none')
$(this).css('filter',"progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+bg+"', sizingMethod='scale');")
return;
}
}
// 2 Traitement des attributs css (background-image)
if($(this).css('backgroundImage')){
var bg = $(this).css('backgroundImage')
if(bg.match(rePng)!=null){
var src = reUrl.exec(bg)
$(this).css('backgroundImage','none')
$(this).css('filter',"progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+src[1]+"', sizingMethod='scale');")
return;
}
}
// 3 Traitement des attributs src de la balise img
if(this.tagName=='IMG'){
var bg= $(this).attr('src')
if(bg.match(rePng)!=null){
$(this).css('filter',"progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+ bg +"', sizingMethod='scale');");
return;
}
}
}
)
} |
Partager