I have a function written in coffeescript that used to work fine but now throws an ‘Invalid Pointer’ exception in ie8.
The Coffee Script
convertSVGforIE = ->
if not $.support.svg or device.ff36
imagesToConvert = $('img.SVG')
imagesToConvert.each ->
imageSrcMinus = this.src.substr 0, this.src.length - 3
this.src = imageSrcMinus + 'png'
The Javascript
convertSVGforIE = function() {
var imagesToConvert;
if (!$.support.svg || device.ff36) {
imagesToConvert = $('img.SVG');
return imagesToConvert.each(function() {
var imageSrcMinus;
imageSrcMinus = this.src.substr(0, this.src.length - 3); //Invalid pointer
return this.src = imageSrcMinus + 'png';
});
}
};
I can’t see anything wrong with my script. Please help me determine, what is ie8’s problem.
UPDATE:
I got this to work, but not in a good way
convertSVGforIE = ->
if not $.support.svg or device.ff36
$('img.SVG').each ->
that = $(this)
imageSrcMinus = that.attr('src').substr 0, that.attr('src').length - 3
that.attr 'src', imageSrcMinus+'png'
The above script works, but why does $(this).attr(‘src’) work? while this.src does not? And why only in IE?
If you look at http://msdn.microsoft.com/en-us/library/ms534643(v=vs.85).aspx, it says that
elem.srcfrom IE8 or later, andIf you look at the comments on that page, there are other quirks as well..
Using jQuery is certainly the easiest fix here, with the pleasant side effect of IE6-7 compatibility, but you may also want to try adding
to the head of the page to force IE8 into Standards Mode.