It is not recommended to disable the Right-Click on any web page. Anyone with basic understanding of browsers can view the source and extract the information they need.
No matter what we do, We cannot prevent users from having full access to the page content. oncontextmenu event can be disabled by disabling the Javascript on the webpage. But it's good to know a way to disable the right-click on page if you ever needed.
You can disable Right-Click on web page using contextmenu
HTML Event. The contextmenu
event occurs when the user right-clicks on an element to open the context menu.
<body oncontextmenu="return false">
<div>...</div>
</body>
NOTE :- If you want users to stop copying page content then use oncontextmenu
along with CSS directive user-select: none
.
user-select: none
will disable any selection on web page. User won't be able to select the any text or image after that.
Top comments (2)
Can you think of any reason to do this?
Not any other than if client ask you to do specifically ....