This article mainly summarizes several common methods for disabling right-click and mouse drag on the webpage. it is very practical and can be used as a reference by a small partner.
1. right-click prohibited menu:
There are two ways to disable right-clicking
1. add a Javascript event handle to the Body tag of the HTML element. the code is as follows:
The code is as follows:
Note: You can also disable right-click at the specified position on the webpage. for example, you only want to disable right-click on an image on the webpage to prevent download, alternatively, you only need to right-click a text or table on the webpage. you only need to add the above red code to the corresponding HTML tag element, for example:
The code is as follows:
2. compile a Javascript function and call the event processing code as follows:
The code is as follows: