I want Block Inspect on the particular HTML page. With support only google chrome. Please provide some code.

2 Answers

1
SAVe On Best Solutions

Try this code --

$(document).keydown(function (event) {
  if (event.keyCode == 123) {
    return false;
  } else if ((event.ctrlKey && event.shiftKey && event.keyCode == 73) || (event.ctrlKey && event.shiftKey && event.keyCode == 74) || (event.ctrlKey && event.keyCode == 75) ||  (event.ctrlKey && event.keyCode == 67) || (event.ctrlKey && event.keyCode == 9)) {
    return false;
  }
});
0
Hien Nguyen On

You should block the user to perform below actions,

Right Click

F12

Ctrl + Shift + I

Ctrl + Shift + J

Ctrl + Shift + C

Ctrl + U

More at Is it possible to remove "Inspect Element"?

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;
  }
}