开发者

Sometimes alert() makes IE do things which IE rejects to do without it

IE is causing problems on totally blank space (not merely but totally). Then when I'm trying to put an alert box somewhere in between the not working code, all of a sudden, it starts to execute the whole logic after alert!.. If I remove alert() it goes blank again.

What is this?? Has anyone ever encountered anything like this? It's already the second time I observed this, first one was couple of years ago, when I was just starting. 开发者_如何学GoBut here it is again and I can't explain it.


Without seeing your code, I can't be sure, but it sounds like the culprit could either be a syntax error that you are inadvertantly fixing when you add the alert (as suggested in a comment by @g.d.d.c) or by a timing issue.

I have seen timing issues manifest like this before, where the code after your alert expects something to have happened that has not happened yet. For example, if your code executes as the page is loaded (ie, it is in a bare <script> block, and not in a function that is executed after the page loads) it may be expecting some specific node to be in the DOM, but it is loaded later in the page.

This could also be caused by an AJAX call that was initiated before your alert, and the code after the alert expects the AJAX call to have returned by the time it executes. Remember that the A in AJAX stands for asynchronous. The call is initiated, and then execution continues in the browser while the HTTP request is being handled by the server.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜