简体   繁体   English

带有匿名功能的IE8 setTimeout

[英]IE8 setTimeout with Anonymous function

I have ajax code that changes the width of a div depending on the percent received and then loops the function again. 我有一个ajax代码,它根据收到的百分比更改div的宽度,然后再次循环该函数。 The way I have it setup now works flawlessly in google chrome and FF but in IE8 (only IE i've tested it on) it freezes on the 我安装它的方式现在可以在谷歌浏览器和FF中完美运行,但是在IE8(仅我已对其进行测试的IE8)中,它冻结在

Here is a screen shot of the debugger. 这是调试器的屏幕截图。 Its showing where it was currently processing and it never left that spot ever. 它显示了当前正在处理的位置,并且从未离开过该位置。 I've changes the timeout to 1000 and 1 didn't make difference. 我已将超时更改为1000,而1没有任何区别。

onSubmit is an event handler, and you're only delaying the function by 1ms, my guess is that Chrome & FF are ignoring this code, and IE is failing on it because IE is stupid. onSubmit是一个事件处理程序,您只将函数延迟了1毫秒,我的猜测是Chrome和FF忽略了此代码,而IE却因为IE愚蠢而失败。

EDIT oh yah, IE doesn't bubble onSubmit like everybody else because IE is stupid. 编辑哦,是的,IE不会像其他任何人一样冒泡onSubmit,因为IE是愚蠢的。

EDIT2 whole code for OP here: http://pastebin.com/t8vdK8B2 此处的OP的EDIT2完整代码: http//pastebin.com/t8vdK8B2

apparently onSubmit is the name of a function in this code, it is also an event handler. 显然, onSubmit是此代码中函数的名称,它也是事件处理程序。 Since functions are not polymorphic this should overwrite, but since it's an event handler I'm not sure. 由于函数不是多态的,因此应该覆盖,但是由于它是事件处理程序,所以我不确定。

Edit 3 编辑3

Ok, so this onSubmit function should work and leave the event handler alone, but I suggest changing this functions name, what it looks like you're doing is trying to pass a variable to the function within a setTimeout you can do that like this: 好的,因此此onSubmit函数应该可以正常工作,而不必保留事件处理程序,但是我建议更改此函数名称,您正在执行的操作是尝试将变量传递给setTimeout的函数,您可以这样执行:

setTimeout(onSubmit,1,id);

The onSubmit event doesn't bubble up in IE so you need to add the on submit event to the form directly. IE中的onSubmit事件不会冒泡,因此您需要将on Submit事件直接添加到表单中。 Eg: 例如:

setTimeout(function(){document.getElementById("formToSubmit").onSubmit(upload_id); }, 1);

Here are details of browsers support of the submit event. 这是浏览器对Submit事件支持的详细信息

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM