Easiest way to Disable mouse right click using Javascript

In this article today I am going to explain easiest way to disable mouse right click using Javascript

Description:

Sometimes we need to disable the mouse right click to protect the content/images. I have an page and want to disable the right click on it. Add the below given script in head section of page.
<script src="//code.jquery.com/jquery-1.10.2.js"></script>
    <script src="//code.jquery.com/ui/1.11.2/jquery-ui.js"></script>
  <script type="text/javascript">
        $(document).bind("contextmenu", function (e) {
            e.preventDefault();
        });
</script>

If you want to show message on right click so add the below given script.
  <script type="text/javascript">
        $(document).bind("contextmenu", function (e) {
            e.preventDefault();
            alert("Right Click is disabled!!!");
        });
</script>

Run the project and check the result.


Note: Right click disable does not protect the content of the website. User can check the page source (Control+U) or can disable the Javascript.

Demo:
Easiest way to Disable mouse right click using Javascript


  In this article we have learn easiest way to disable the mouse right click using Javascript in Asp.net(C#, VB). I hope you enjoyed this article. 

Post a Comment

[blogger]

MKRdezign

Contact Form

Name

Email *

Message *

Powered by Blogger.
Javascript DisablePlease Enable Javascript To See All Widget