对于IE7 / 8,循环太慢了 [英] loop is too slow for IE7/8

查看:158
本文介绍了对于IE7 / 8,循环太慢了的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个循环执行需要在所有浏览器中运行。

I have a loop execution that needs to run in all browsers.

在chrome / ff等执行运行得很快。在IE中它很慢并且最终会发出一个提示,说脚本运行缓慢(不好)。

in chrome/ff etc the execution runs fast and fine. in IE it's slow and end's up dispatching a prompt saying a script is running slow (no good).

有关如何绕过这样的事情的任何想法?我大多只需要摆脱IE提示7/8

Any ideas on how to get around something like this? I mostly just need to get rid of the IE prompt for 7/8

**编辑**

这是代码:

if(this.handicap()) {
    while(this.hasGraphChanged()) {
        this.gravity(this.separate());
    }
}

这是一个非常大的项目,所以不是列出所有代码,我都会快速解释一下。

This is a VERY large project, so instead of listing all the code, I'll go for a quick explanation.

this.handicap:如果浏览器IE7 / 8
this.hasChanged:返回,则返回true true / false取决于绘制更新后是否有更改
this.gravity:处理基于p1(数组)的绘制算法

this.handicap: returns true if the browser if IE7/8 this.hasChanged: returns true/false depending if there is a change AFTER a draw update this.gravity: processes drawing algorithm based on p1(array)

推荐答案

您可以使用一些异步迭代技术而不是循环。观看Pedro Teixeira的异步迭代模式,以获得精彩的介绍。它使用Node.js,但您可以在浏览器中使用相同的模式。

You can use some asynchronous iteration technique instead of loops. Watch Asynchronous Iteration Patterns by Pedro Teixeira for a nice introduction. It uses Node.js but you can use the same patterns in the browser.

这篇关于对于IE7 / 8,循环太慢了的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆