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

前端 未结 8 1360
情歌与酒
情歌与酒 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:02

    Most of the other solutions should work great, but here's a short one liner if you don't care about catching log messages if the console is not available.

    // Stub hack to prevent errors in IE
    console = window.console || { log: function() {} };
    

    This lets you still use the native console.log function directly still instead of wrapping it with anything or having a conditional each time.

提交回复
热议问题