How to disable or block F12 button in Internet Explorer 9 using Javascript/jQuery?
Asked
Active
Viewed 1,003 times
-1
-
1Not sure you can stop someone from using a part of the browser that has nothing to do with the web content - at least, I hope you can't! ... have you tried listening for key events – Jaromanda X Feb 20 '16 at 06:16
-
Yes, I tried it.. but no success. – vedu Feb 20 '16 at 06:22
-
Possible duplicate of [How can I block f12 keyboard key in jquery for all my pages and elements?](http://stackoverflow.com/questions/28575722/how-can-i-block-f12-keyboard-key-in-jquery-for-all-my-pages-and-elements) – NapkinHD Feb 24 '16 at 09:52
1 Answers
1
Here 123 is the keycode of the F12 key, which prevents from opening the Inspect Element screen in the browser. On keyDown return false that does not open Inspect Element screen.
$(document).keydown(function(event){
if(event.keyCode==123){
return false;
} else if(event.ctrlKey && event.shiftKey && event.keyCode==73){
return false; //Prevent from ctrl+shift+i
}
});
Prevent Right Click Inspect Element
$(document).on("contextmenu",function(e){
e.preventDefault();
});
-
Of course someone who knows enough to inspect elements can disable that in about, oh, 5.8 seconds. – dda Feb 23 '16 at 07:20
-
Thank you for your answer but I have already tried this code. It is working fine in chorme, mozilla, IE 8 but It is not working in IE 9! – vedu Feb 27 '16 at 06:19