|
TODO intro The code/**
* Sets the background of an element to a transparent image in a browser-
* independent manner.
*
* This function does not support repeating backgrounds or alternate background
* positions to match the behavior of Internet Explorer. It also does not
* support sizingMethods other than crop since they cannot be replicated in
* browsers other than Internet Explorer.
*
* @param {Element} el
* @param {String} src The image source URL
*/
goog.style.setTransparentBackgroundImage = function(el, src) {
var style = el.style;
if ('filter' in style) {
style.filter = 'progid:DXImageTransform.Microsoft.AlphaImageLoader(' +
'src="' + src + '", sizingMethod="crop")';
} else {
// Set style properties individually instead of using background shorthand
// to prevent overwriting a pre-existing background color.
style.backgroundImage = 'url(' + src + ')';
style.backgroundPosition = 'top left';
style.backgroundRepeat = 'no-repeat';
}
};The code walkthroughTODO walkthrough Further readingTODO further reading
|
También se puede utilizar un fichero HTC externo para cargar el script. Más info: http://www.exelweiss.com/blog/259/solucion-png-transparencia-ie-internet-explorer-6/
Can I use PNG images?
Yes! This method created for png images displaying in IE. All gecko based browsers shows png alfa correctly.
I'm not quite sure what to replace within the code. I'm putting this directly in the style sheet, correct? And from there, I would replace the style.backgroundImages = url. Do I replace everything in the url('+src+')? Also, do I have to do anything else to this code. Any help is much appreciated. Thanks!