Reputation: 53
How can I detect the Developer Tools is running on IE 10 with JavaScript?
I tried:
if (console && console.log) {
alert("Developer tools is running");
}
Upvotes: 0
Views: 1424
Reputation: 3286
In IE 10 you can call
window.__IE_DEVTOOLBAR_CONSOLE_COMMAND_LINE
if it is an object the toolbar is open. (Be careful: it stays if you have opened the toolbar in the same 'window' before) if it is 'undefined' the toolbar is closed.
Upvotes: 1
Reputation: 1
As Arbitter and Jazza have already stated, it's not really possible.
Perhaps not useful to you but the only way I've been able to interact with the Developer Tools is using the JavaScript statement:
debugger;
This will cause a breakpoint to be hit if debugging with Developer Tools.
Upvotes: 0
Reputation: 3553
AFAIK not really possible. if( console.log )
would check if console.log()
is an available function, so it will return true.
But of course this has nothing to do dev whether the tools are open or not.
Upvotes: 0
Reputation: 3016
In previous versions of IE and in all other modern browsers you can't tell if the Developer Tools or Web Inspector are open. I assume the same is for IE10.
You can check if the browser supports console logging by using:
if ('console' in window) {
if ('log' in console) {
console.log('This will work.');
}
}
IE8 and below may not support console logging, so it's wise to check if they do before logging to the console in your code.
Upvotes: 0