Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does IE9 enable 'something' when using developer tools?

Im using Google Maps Javascript API V3, and recently the icons on my map aren't showing up in IE9.

To get to the bottom of it, I turned on IE's developer tools. When I refreshed the map, the icons appeared! However, when I close out of IE and start anew, the icons aren't there. Yet again, if I turn on the developer tools and refresh, the icons appear.

My question is the title of this topic, what is enabled when accessing IE's developer tools, which is allowing my icons on my Google map to appear??

like image 571
Josh Avatar asked May 02 '12 14:05

Josh


People also ask

Why does javascript only work after opening developer tools?

The console object is only activated when the Dev Toolbar is opened. Prior to that, calling the console object will result in it being reported as undefined . After the toolbar has been opened, the console will exist (even if the toolbar is subsequently closed), so your console calls will then work.

What are the properties of IE developer tools?

It allows validating of CSS and HTML, previewing page layout at various resolutions, and also offers a ruler (measuring in pixels) to aid in positioning the elements.

What is F12 console?

Developer tools allow us to see errors, run commands, examine variables, and much more. They can be opened with F12 for most browsers on Windows.


2 Answers

If you have any console prints in your code, these would throw exceptions (hence breaking the javascript after it) if the page was loaded when the developer tools were closed.

to fix this, wrap your prints in an if statement:

if (console) {
   console.log('...');
}
like image 95
jbabey Avatar answered Sep 20 '22 06:09

jbabey


Any references to the global console object will only work if the IE Developer Tools are open. If the developer tools are closed, the global console object is undefined.

For example, the following code will only run if the developer tools are open. If they're closed, they'll throw an error about console being undefined:

console.log("test");
like image 25
Jon Benedicto Avatar answered Sep 23 '22 06:09

Jon Benedicto