请教一个问题。关于在ie浏览器下的定时器每次执行以后会需要更多的时间来执行的问题?
发布于 1 天前 作者 CokeWithIce 113 次浏览 来自 问答

问题图片.png

如图所示。我次项目的是添加了一个定时器。在ie(全本版本)浏览器上使用以后会穿线一个问题就是每次执行以后下次执行会比上次执行时间更长。 耗时更多的部分就是黑线圈起来的部分。(计时器部分) 下面是代码 Iframe.prototype.init=function(){ var self=this; this.seamless=$(this.element).attr(“seamless”); if(this.element.src.indexOf("%7B")!="-1"){ return false; } if(typeof(this.seamless)!=“undefined”){ var intervalTime=400; try{ window.clearInterval(this.timer); }catch(e){} this.timer=setInterval(function(){self.update()},intervalTime); return ; } Iframe.prototype.update=function(intervalTime){ if(this.element.contentWindow.document.body!=null){ $(this.element).contents().find(“body”).css(“height”,“auto”); $(this.element).contents().find(“html”).css(“height”,“auto”); var scrollHeightForBody; if($(this.element).contents().find("#body").length==1){ scrollHeightForBody=$(this.element).contents().find("#body").height(); }else{ scrollHeightForBody=$(this.element).contents().find(“body”).height(); } $(this.element).css(“height”,scrollHeightForBody+“px”) }

}
init方法和update方法都是执行的。但是这个定时器问题就是没法解决。希望能有高手来帮我下。多谢了。现在我最希望知道的是成因。。。
回到顶部