11

For some reason, in IE8, javascript is not running unless I reload the page with Developer Tools open. I close developer tools and reload the page and the javascript stops working. I'm not getting any error reports (not that they'd be any use anyway).

Anyone else had this problem?

Joel
  • 2,185
  • 4
  • 29
  • 56

2 Answers2

20

Often that's because you left a console.log call in your script. This only works when a debugger is present. You should get a JS error on trying to use it unless you have them turned off.

bobince
  • 528,062
  • 107
  • 651
  • 834
  • I usually use: if (console) { console.log(object); } – Kyle B. Nov 09 '09 at 15:40
  • I've never used console.log. And I've not disabled javascript errors. :/ – Joel Nov 10 '09 at 11:23
  • 1
    It's 2012, the answer is still correct. Under Internet Options -> Advanced -> Browsing -> Unchecking "Disable script debugging" gives you console object without dev tools open. So I did this at the beginning of my code: `window.console = window.console || {log: function() {}};` – Tony Abou-Assaleh Jun 10 '12 at 22:30
  • Just saved me hours of debugging! Thanks :-) – Liam Wheldon Nov 17 '16 at 11:00
0

Close Developer Tools, close IE8, re-open, refresh with clear-cache: CTRL-F5 This should do the trick if you don't have any special JavaScript communicating with Developer Tools.

Christopher Tokar
  • 11,644
  • 9
  • 38
  • 56