Disable a right click in JavaScript – Advantages and Disadvantages

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.

ExplanationThis 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.

Disable a right click in JavaScript - Advantages and Disadvantages

Figure: Disable a right click in JavaScript – Advantages and Disadvantages

For some low-level security, we disable a right click on our website. Because we work on our website, we use different tools, images and provide valuable contents, we must protect our source code from other visitors.

We can disable the right click with

A script in the following way.

We disable a right click with javascript code: this line can be inline in HTML code for disabling right click on our web pages.

We can apply this code only when JavaScript is enabling.

The above code can easily block the right click on our web page. This code is inline in our HTML code.

Another way of disabling the right click in javascript.

This code will also disable the right click of mouse, Ctrl + Shift + I, Ctrl+ Shift + J, Ctrl + S, Ctrl + U, and F12 key. The F12 key uses for viewing the source code of the page, so it also need be disabled. That’s the way we also need to disable this code.

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 (rightclick and select “Toggle”.

 

Latest posts by Prof. Fazal Rehman Shamil (see all)

Buy advertisement space on T4Tutorials

For more details email [email protected]