Some Javascript is not working until hitting F12 in IE 11

旧城冷巷雨未停 提交于 2021-02-08 12:13:40

问题


The Javascript code is working correctly in Firefox and Chrome, but for IE(I am using 11),it's not working until I hit F12 for debugging. And there is also no error displayed in debugger in IE. Any idea why?

The first function is to check if the browser support classList or not, apparently, IE doesn't support it. Here is the code:

function checkClassListSupport() {
    var supportsClassList = ({}).toString.call(document.body.classList) == "[object DOMTokenList]";
    return supportsClassList;
}

回答1:


It's working now if I remove the console.log code, or change the document module to "Edge".



来源:https://stackoverflow.com/questions/52653611/some-javascript-is-not-working-until-hitting-f12-in-ie-11

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!