I want Block Inspect on the particular HTML page. With support only google chrome. Please provide some code.
Asked
Active
Viewed 798 times
-2
-
1It's not possible to do this. Sure there are some short-sighted solutions, as in the answers below, but there is *always* a way around it. Your effort would be much better spent on sanitising the data you receive in each request on the server to ensure it's valid. – Rory McCrossan Apr 16 '19 at 14:17
2 Answers
1
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;
}
}

Hien Nguyen
- 24,551
- 7
- 52
- 62
-
You could do this, then I'll just right click -> Inspect element. If you disable that then I'll temporarily disable JS, then open dev tools. In other words, there is no single worthwhile way of stopping people accessing dev tools, and neither should you waste your time trying. – Rory McCrossan Apr 16 '19 at 14:20
-
1Also, if you believe the question is a duplicate, then please vote to close it as such. Copying an answer from elsewhere is effectively plagiarism. – Rory McCrossan Apr 16 '19 at 14:21
-
0
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;
}
});

Rory McCrossan
- 331,213
- 40
- 305
- 339

SAVe
- 814
- 6
- 22
-
You could do this, then I'll just right click -> Inspect element. If you disable that then I'll temporarily disable JS, then open dev tools. In other words, there is no single worthwhile way of stopping people accessing dev tools, and neither should you waste your time trying. – Rory McCrossan Apr 16 '19 at 14:20
-
@SAVe: Thanks to its work. But inspect element also open Another browser. – Ganesh Wagh Apr 17 '19 at 05:25