我有一个用coffeescript编写的函数,用于正常工作,但现在在ie8中引发'Invalid Pointer'异常。ie8'无效指针'
的咖啡脚本
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'
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';
});
}
};
我看不出什么毛病我的脚本。请帮我确定,ie8的问题是什么。
更新: 我得到这个工作,但不是一个好办法
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'
以上脚本的工作,但为什么$(本).attr( 'SRC')工作吗?而这个.src不?为什么只在IE浏览器?
将一个断点和看看this.src和this.src.length是什么;在产生错误的线上。 – 2012-03-11 21:57:08
我不确定你的意思是断点。你能把我链接到一些文档吗? – Fresheyeball 2012-03-11 22:08:57
这是另一个堆栈溢出问题,详细介绍IE8中Javascript的调试; http://stackoverflow.com/questions/1306232/how-to-debug-javascript-with-ie-8。至于为什么; – 2012-03-11 23:48:52