Introduction:
We can prevent
copying of text and images from our webpage. In this article I am going to explain
two different methods
to prevent the mouse right
click on asp.net web page using jQuery to avoid/protect the images from being
copied or preventing HTML Source code of the page from being seen.
Benefits of Disabling right click on page:
Benefits of Disabling right click on page:
- User cannot view the HTML Source of the page.
- User cannot copy the images from the page.
- User cannot paste directly in form’s input controls. User has
to write in text box.
First Method:
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title>Disable
Right Click on web page using jQuery</title>
<script
src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script
type="text/javascript">
$(function
() {
$(this).on("contextmenu", function
() {
return
false;
});
});
</script>
</head>
<body>
<form
id="form1"
runat="server">
<fieldset
style="width:300px;">
<legend><strong>Disable right Click On Images </strong></legend>
<br
/>
<div
>
In this article I am going to share two
ways to prevent the right click only on specific images or all images rather
than all the contents(text and images)
in asp.net web page using jQuery to avoid/protect the images from being
downloaded.
<br />
<br />
<img src="a7a7a251ce5e187543a75b09.jpg" />
</div>
</fieldset>
</form>
</body>
</html>
Second Method:
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title>Disable
Right Click on web page using jQuery</title>
<script
src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script type="text/javascript">
$(function () {
$(this).on("contextmenu", function (event) {
event.preventDefault();
});
});
</script>
</head>
<body>
<form
id="form1"
runat="server">
<fieldset
style="width:300px;">
<legend><strong>Disable right Click On Images </strong></legend>
<br
/>
<div
>
In this article I am going to share two ways
to prevent the right click only on specific images or all images rather than
all the contents(text and images) in
asp.net web page using jQuery to avoid/protect the images from being
downloaded.
<br />
<br />
<img src="a7a7a251ce5e187543a75b09.jpg" />
</div>
</fieldset>
</form>
</body>
</html>
0 comments:
Post a Comment