Block inspect element in your website


Introduction
It is not really possible to completely block inspect element on your website.
But you can block some popular ways of accessing it. some of them include

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

What you need

  • Basic JavaScript knowledge
  • HTML editor

I tested with Chrome browser & fire foz. 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;
  }
}




Comments

Popular posts from this blog

How To Migrate MVC 3 Application To MVC 5

Populate a drop-down in Vue.js and Asp.net Core from an ajax call

Building a CRUD Application with Ag-Grid