How to disable opening dev console in browser
In order to disable dev console in browser, you need to disable two things.
- Right click
- ctrl+shift+I
Disable right click
document.addEventListener('contextmenu', event => event.preventDefault());
For more info visit
Disable ctrl+shift+I
document.body.addEventListener("keydown", (e) => {
if(e.ctrlKey && e.shiftKey && e.key == "I")
e.preventDefault();
})
For more info visit
Note:
There is still some ways to get around this technique and user can open dev console on your website, can you guess what it is?
Top comments (7)
1) Disabling right click is a sin, and whoever does it will reserve their place in hell.
2) why would you need to disable opening dev console?
People think doing this coupled with disabling selecting text (the 2nd deadly sin) protects their content...I am not sure who told people that though 😂
Offcource, it can prevent this some extent.
Disabling dev console can prevent users from reading
url
of some static resources. This method will work for users who don't have much patience or who don't know how can bypass this method.If we are developing a website for online exam, then disabling right click
(context menu)
would prevent user to do copy paste.Disable javascript in browser
Use your browser menus to open the tools as well.
yeah, we can also open website after opening dev console.