Disable a right click in JavaScript – Advantages and Disadvantages
Sometimes you want to protect your content from a user who copying the data about the website such as designing, code, images locations, addresses, application access, etc. Most of the users of the website use the right click button to display or viewing the information about your website. If you like or want to protect the website you must need to disable the right click. On your web pages, the following script will help you to protect the web site. Explanation: This is a script that will secure or save the default right menu from others users when we clicked the right mouse button on web .must stop the use of this, because it can easily be done viewing its source, or taking images or contents off your site when using either IE 4+ or NS 4+. Very useful or helpful for many web site designer and owner.
1 2 |
Javdocument.addEventListener ("contextmenu", function (s) { s.preventDefault ();(False);} |
1 2 |
document.addEventListener (“contextmenu”, function (s){s.preventDefault (); False} |
Advantages of disabling a right click in JavaScript
- When we work hard on our web site, we must want to protect our images contents code from other users.
- When we disable right click on the web page. it is a warning for visitors that contents is copyrighted.
- In such way, we can easily protect our source code from other visitors.
- Disabling the right click annoying the user.
- We can easily protect our important data and images.
- It’s very useful and easy with javascript
Disadvantages of disabling a right click in JavaScript
For this work, JavaScript must be enabled on the browser.- When we disable right click we must enable a javascript.
- JavaScriptis a very widely used scripting language.
- If they are disabledfor some reason, then the content of Web Page or its … Then Toggle “JavaScript. Enabled” preference (right–click and select “Toggle”.