Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to remove "Inspect Element"?

Is it possible to remove or disable "Inspect Element" context menu in Chrome App via Javascript?

I have searched through several forums but there are no definite answer.

like image 585
Kim Honoridez Avatar asked Feb 24 '15 07:02

Kim Honoridez


People also ask

How do I turn off Inspect Element in Chrome?

We can hide an element by inspecting it with Chrome DevTools, right-clicking the element under the Elements tab, and choosing the Hide element menu from the context menu. If you're a fan of using the shortcut, then pressing the <kbd>h</kbd> key has the same effect.

Is inspect element permanent?

Permanent Inspect Element. This extension lets you save the changes you make to a static web page using Inspect Element to remain there even after you refresh the page.

Can you block inspect element on my website?

There are many ways to inspect the code of the website or find the words in the code etc. For Example: by right-click, by pressing key F12, by ctrl+shift+i, by ctrl+f, etc. So to disable these keys or clicks, copy the below code and paste it on your website page.


2 Answers

I have one requirement for one page. In that page I want to block the user to perform below actions,

  • Right Click
  • F12
  • Ctrl + Shift + I
  • Ctrl + Shift + J
  • Ctrl + Shift + C
  • Ctrl + U

For this I googled, finally got the below link,

http://andrewstutorials.blogspot.in/2014/03/disable-ways-to-open-inspect-element-in.html

I tested with it with Chrome & Firefox. It's working for my requirement.

Right Click

 <body oncontextmenu="return false"> 

Keys

document.onkeydown = function(e) {   if(event.keyCode == 123) {      return false;   }   if(e.ctrlKey && e.shiftKey && e.keyCode == 'I'.charCodeAt(0)) {      return false;   }   if(e.ctrlKey && e.shiftKey && e.keyCode == 'C'.charCodeAt(0)) {      return false;   }   if(e.ctrlKey && e.shiftKey && e.keyCode == 'J'.charCodeAt(0)) {      return false;   }   if(e.ctrlKey && e.keyCode == 'U'.charCodeAt(0)) {      return false;   } } 
like image 73
ramakrishna Avatar answered Sep 17 '22 10:09

ramakrishna


It is possible to prevent the user from opening the context menu by right clicking like this (javascript):

document.addEventListener('contextmenu', function(e) {   e.preventDefault(); }); 

By listening to the contextmenu event and preventing the default behavior which is "showing the menu", the menu won't be shown. But the user will still be able to inspect code through the console (by pressing F12 in Chrome for example).

like image 35
Guillaume Avatar answered Sep 17 '22 10:09

Guillaume