This is a bit maddening. I have code which saves the current background-image from a selected element into a variable, which I then use to create an img tag.
Simply put, the following works in all browsers I've tested except IE6:
var bg = $('.element_selector').css('background-image');
The return value from IE6 is 'none', which is incorrect. (Before anyone suggests trying 'backgroundImage' instead of 'background-image', no dice.)
Any ideas on how I can get that value?
Update: I forgot to mention that the background image in question was processed by DD_belatedPNG, which now appears to be the culprit -- if I comment out the fix, I get my value. If anyone knows offhand how I could still fetch that value after the png fix is in, please let me know.
After some testing in IE6 I was able to reproduce your issue with DD_belatedPNG and background src.
Here's what I've found. If you set the
background-imagevariable before callingDD_belatedPNG.fix('[selector]');then you get the desired result. If you're setting it afterward for instance in aclickevent you get a value of"none".Additionally, DD_belatedPNG adds an image element to the page containing your background image (with a class of
DD_belatedPNG_sizeFinder), so you can potentially 1) re-use, 2) copy, or 3) takesrcattribute value from that element.Here's my testing code:
CSS:
HTML:
jQuery: