views:

42

answers:

1

It is already a second time when IE causes 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 anywhere ever encountered anything like this? It's already second time I observe this, first one was couple of years ago, when I was just starting. But here it is again and I can't explain it.

+3  A: 

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.

pkaeding
+1 for managing to give such a coherent answer based on so little information :)
psmears
Hi, thanks for great response. I think it was a timing issue, although it turned out to be pretty buggy and that's why it was not exactly obvious at first sight. I was preloading an image, and checking for .complete property on load event. While this works fine in all browsers, in IE for some reason .complete property gives false when onload is fired. Alert was giving me a time break.
jayarjo
By the way looks like there's a lot of similar problems around. This one for example: http://stackoverflow.com/questions/779379/why-does-settimeoutfn-0-sometimes-help
jayarjo