问题
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