How can I disable inspect and view page source? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

How can I disable inspect and view page source?

I am wondering how can I disable inspect element and view page source on my web-page. I've tried oncontextmenu="return false" But it disables every right clicker functions(copy,paste,cut and etc) So if there is a way to make it pls Help me.

24th May 2019, 10:35 AM
Ilia Sichinava
Ilia Sichinava - avatar
2 Answers
+ 1
You can't disable them. they are the features of the browser. imagine what would happen if js was given the ability to access all browser functions without any restriction. all you could do is to disable the context menu and design a new context menu with html/css and make it visible whenever the right mouse button is pressed. there are more problems with implementing copy and paste using js. give the user an advice to use keyboard shortcuts. edit: this still wouldn't entirely secure you from the intruder as there are keyboard shortcuts that can be used to access Dev tools.
24th May 2019, 10:40 AM
Farry
Farry - avatar
0
Thank you, makes sense
24th May 2019, 10:46 AM
Ilia Sichinava
Ilia Sichinava - avatar