Sometimes we do not want users who browse our website to view the source code of our website or right-click to copy the content of our article. So what we can do at this time is to shield the user's right-click action. So that the user does not respond when right-clicking on our webpage. For specific operations, see the following code (this code is compatible with both IE and firefox ):
// Hide right-click and right-click document. oncontextmenu = function () {alert ('prohibit right-click menu! '); Return false ;}
By adding the above js Code segment to our js code, you can right-click the user who browses the website.
Articles you may be interested in
- Js shields mouse and keyboard events (including right-click, direction key, backspace key, F5 refresh key, etc.), compatible with IE and firefox
- Javascript determines whether the mouse is left or right-click-compatible with ie, firefox, chrome, and other major browsers
- Js shield direction keys, compatible with IE and firefox
- Js to get the current mouse position, compatible with ie and firefox
- Javascript to get the current mouse position (compatible with IE and firefox)
- Js can only enter numbers and numbers with decimal points, compatible with IE and firefox
- Javascript blocking window close, compatible with IE and firefox
- Js obtains the height of the scroll bar from the top and bottom of the browser. It is compatible with ie and firefox.