【发布时间】:2011-03-23 18:01:30
【问题描述】:
我们的一个开发人员一起使用了一个横幅旋转器,虽然它在 NOT IE 中运行良好,但 IE 在第 30 行抛出了一个错误(下面用“***** ERROR ON NEXT LINE”标记)。我可以不排序 $$('.banner') 吗?
错误是: '对象不支持此属性或方法'
使用原型 1.6.0.3
function changeBanners() {
// banners are now sorted by their z index so that
// the ones most in front should be most on top in the DOM
// ***** ERROR ON NEXT LINE
banners = $$('.banner').sort(function (a,b){
_a = parseInt(a.style.zIndex);
_b = parseInt(b.style.zIndex);
return _a < _b ? 1 : _a > _b ? -1 : 0;
});
// increment z index on all of the banners
Element.extend(banners);
banners.each( function (banner){
Element.extend(banner);
banner.style.zIndex = parseInt(banner.style.zIndex) + 1;
});
// move the first banner to be the last
first_banner = banners.shift();
banners.push(first_banner);
// set it invisible
Effect.toggle( first_banner.id , 'appear' , {
duration: 2.0,
afterFinish: function(){
first_banner.style.zIndex = 0; // update its z index so that it is at the end in the DOM also
first_banner.show(); // make it reappear so that when the one in front of it disappears, it will show through
}
});
};
【问题讨论】:
-
尝试将一个空函数传递给
sort方法并检查错误。 -
一个空函数抛出“预期数字”。将 a > b 作为排序函数返回“对象不支持此属性或方法”错误。
-
Crescent - 同样的错误 - IE 可怕的调试器在“finally {” onTimerEvent: function() { if (!this.currentlyExecuting) { try { this.currentlyExecuting = true; this.execute(); } 最后 { this.currentlyExecuting = false; } } } });
-
@Jarrett:见webbugtrack.blogspot.com/2007/11/…
-
@Crescent Fresh - 这听起来像是我的问题,但我使用 element.extend 进行的上述修复仍然产生相同的结果。你有没有看到我可能错过的任何具体内容?谢谢!
标签: javascript internet-explorer prototypejs