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

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

    The console.log wrapper that I used was not sufficient to detect the console in IE9. Here's the wrapper that works from a related question on SE:

    function logError(msg){
        try {
            console.log(msg);
        } catch (error) {
            throw new Error(msg);
        }
    }
    
    function log(msg){
        try {
            console.log(msg);
        } catch (error) { }
    }
    

    A proper test for the availability of the console object would be: if (typeof console === "undefined" || typeof console.log === "undefined")

提交回复
热议问题