javascript code to not right click on a web page
You can use JavaScript to prevent the right-click menu from appearing on a web page. Here is an example code:
document.addEventListener('contextmenu', event => event.preventDefault());
This code adds an event listener to the contextmenu
event, which is triggered when the user right-clicks on the web page. The preventDefault()
method is called to prevent the default behavior of the event, which is to display the context menu.
Note that disabling the right-click menu can interfere with user accessibility and can also be bypassed using browser extensions or by disabling JavaScript. Additionally, disabling right-clicking can make it difficult for users to access certain browser features, such as opening links in a new tab or saving images. Therefore, it is generally not recommended to disable right-clicking on a web page.