Description:

In this article, I will explain how to disable right click option on webpage using Jquery.  

In some scenario, it is required to prevent our web page content or images from being copied by another one. We can secure our content or images by disabling right click option on the image.

This is the effective way to prevent our content from being stolen or copied.

If we want to disable right click on entire web page, add oncontextmenu() with body tag.

<body oncontextmenu="return false;">

If we want to disable right click on particular element, add oncontextmenu() with elements.

<img oncontextmenu="return false;" alt="Bluehills" src="Blue%20hills.jpg" />

Example program:

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js">
    </script>
    <script type="text/javascript">
        $(document).ready(function () {
            //Prevent rightclick only with Image element
            $('#ImgId').on("contextmenu", function (e) {
                alert("Right Click is not allowed on this image");
                return false;
            });
            //Prevent rightclick on the entire page
            $(document).on("contextmenu", function (e) {
                alert("Right Click is not allowed on this page");
                return false;
            });
        });
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <p>
            sample content</p>
        <br />
        <div>
            <img id="ImgId" alt="Bluehills" src="Blue%20hills.jpg" />
        </div>
    </div>
    </form>
</body>
</html>

The above example program using on() method to disable right click option for preventing content or images from being stolen or copied.


Disable Right click on webpage  using Jquery, How to prevent right click option using Jquery , Disable right click with Jquery, Disable Mouse Right click using Jquery, Disable right mouse click using Jquery, prevent images from being copied using jquery, prevent right click option on images.

0 comments:

Post a Comment

 
Top