How to disable right key for all image using java script in asp.net c#

In this article, I am trying to protect the image using disable right key of mouse of a form. Through this we can protect all images of a form

Source Code:-

<
html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title> image </title>
  
 
 <script type="text/javascript">
     function disableRightClick() {
         alert("Sorry,Right click is not allowed!!!");
         return false;
     }
</script>
</head>
<body oncontextmenu=" return disableRightClick();" >
    <form id="form1" runat="server">
    <div>
   
        <asp:Image ID="Image1" runat="server" ImageUrl="~/img/image.jpg"
            Width="317px" Height="84px"/>
        <br />
   
    </div>
    </form>
</body>
</html>

Out-Put:-


How to disable right key for all image using java script in asp.net c# How to disable right key for all image using java script in asp.net c# Reviewed by NEERAJ SRIVASTAVA on 11:24:00 AM Rating: 5

No comments:

Powered by Blogger.