internet explorer 8 - IE8 from IE10 downgrade with console -


i need test javascript project uses console-object. downgrade ie10 down ie8 not sure environment-testcases "safe" others.

this how can use console logging in internet explorer? sais console undefined without developertools(f12). current experience console.log available, no matter f12 active or not.

this article sais, enabled. article sais console undefined in ie8.

it looks ie8 != ie8. isnt enougth test pages in ie, firefox, opera , safari?

<html> <body> <script> document.write('console <b>' + typeof console + '</b>! <br />'); document.write('even console.log <b>' + typeof console.log + '</b>!<br />'); document.write(window.navigator.useragent); </script> </body> </html> 

screenshot

re console being undefined: true. ie8 , ie9 define console object when f12 dev tools opened. if dev tools have not been opened, console object undefined , throw fatal errors.

see answer question: why javascript work after opening developer tools in ie once?

there various ways around this, best solution not use console object in production code -- console object not web standard, should not rely on existing (in fact there other browsers in existence don't provide console object @ all).

if must use console in production code, create shim when page loads. this:

if(!window.console) {window.console={log:function(){}};} 

that should prevent throwing fatal errors.

but really, best answer not have console calls in production code. it's intended developer tool, should used in development code.


Comments

Popular posts from this blog

How to mention the localhost in android -

php - Calling a template part from a post -

c# - String.format() DateTime With Arabic culture -