2

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. But here it is again and I can't explain it.

bpeterson76
  • 12,918
  • 5
  • 49
  • 82
jayarjo
  • 16,124
  • 24
  • 94
  • 138
  • I can't tell what you're describing or asking. – Jonathon Faust Jun 25 '10 at 16:30
  • 1
    Without any kind of example of your code, my best guess is a missing semicolon somewhere in your Javascript. Are you minifying / compressing your js files in any way? – g.d.d.c Jun 25 '10 at 16:34
  • Yeah, post some code or this will get closed as "not a real question"... – GalacticCowboy Jun 25 '10 at 16:37
  • I think OP put it best when he said "What is this?? I can't explain it." – Jeriko Jun 25 '10 at 16:55
  • 1
    Actually I was asking very specific thing :) if anyone ever had an alert box that fixed otherwise not working code in IE, while the very same code works fine in all other browsers without any alert. – jayarjo Jun 26 '10 at 06:12

1 Answers1

3

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
  • 36,513
  • 30
  • 103
  • 141
  • 1
    +1 for managing to give such a coherent answer based on so little information :) – psmears Jun 25 '10 at 17:03
  • 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 Jun 26 '10 at 06:18
  • 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 Jun 26 '10 at 06:20