I have a page with JS code. When I open this page in IE9, the code isn't run. However, when I open console with F12 and reload the page the script starts executing. What could be wrong here?
Asked
Active
Viewed 1,063 times
1 Answers
3
Check for the JS error icon on the status bar. You probably are getting something about how console.log
doesn't exist because it doesn't until you open the developer tools (in IE).
A fix for this in your code would be to check for the existence of console.log
and if it doesn't exist, create one.
if (typeof console !== 'object' || typeof console.log !== 'function') {
console.log = function (arg) {
//now you can alert the argument or do whatever even when console.log isn't natively supported
}
}

Jasper
- 75,717
- 14
- 151
- 146
-
Anything starting with `console` actually, though the vast majority of the time, that will be `console.log` – Scott Mermelstein Dec 12 '13 at 20:25