HOW TO DISABLE RIGHT CLICK ON BODY AND IMAGES IN WEB APPLICATION.

Ankit Singh

Total Post:341

Points:2389
Posted by  Ankit Singh
 552  View(s)
Ratings:
Rate this:
I want to Disable right click on body and images in web application .how to do this please help me.
  1. aditya kumar Patel

    Post:254

    Points:1810
    Re: How to Disable right click on body and images in web application.

    Sometimes we required to prevent our web page images from being copied by another Persion.in that case we can secure our images by disabling right click or
     by disabling image context menu on images only. This is an effective approach to prevent our images from being copied  .Add the below event handler to the img  tag  and body as shown below:

    <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Fourm.aspx.cs" Inherits="Forumasp.Fourm" %>
    <!DOCTYPE html>
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <script type="text/javascript">
            function disableRightClick() {
                alert("Sorry, right click is not allowed !!");
                return false;
            }
    </script>  
        <meta charset="utf-8">
        <title>jQuery UI Menu - Categories</title>   
    </head>
    <body  oncontextmenu="return disableRightClick()" >
    <img alt="Image" src="Images/1.jpeg" oncontextmenu="return disableRightClick()"/>

    </body>

    </html>

    c

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!