Website with JS doesn't work in IE9 until the Developer Tools is activated

前端 未结 8 1359
情歌与酒
情歌与酒 2020-12-12 15:53

I\'m developing a complex website that heavily leverages jQuery and a number of scripts. On load of the site, none of my scripting is working (though I can confirm that othe

相关标签:
8条回答
  • 2020-12-12 16:23

    I find it much more convenient to simply use console && console.log('foo', 'bar', 'baz') rather than use a wrapper function.

    The code you provided:

    function logError(msg){
      if (console) {
        console.log(msg);
      } else {
        throw new Error(msg);
      }
    }
    

    Will produce an error for IE when dev tools are closed because console will be undefined.

    0 讨论(0)
  • 2020-12-12 16:24

    You have console calls, in IE these will fail if the dev tools are not open. A simple fix is to wrap any console calls in a function like:

    function log(msg) {
      if(console)
        console.log(msg);
    }
    
    0 讨论(0)
提交回复
热议问题