In this article we will learn how we can disable right click on your asp.net website with the help
on JavaScript. Sometimes you don't want to
allow anyone to copy the text or images from your website pages for the
security of your content and images .So it is recommended to disable the right click on your website so that no
one can copy the content and images from your website. Lets understand this using JavaScript.
- To
do so, place following script in the head tag of your design file
of asp.net
<head
runat="server">
<script language=JavaScript>
var message = "";
function clickIE4() {
if (event.button == 2) {
alert(message);
return false;
}
}
function clickNS4(e)
{
if (document.layers || document.getElementById && !document.all) {
if (e.which == 2 || e.which == 3) {
alert(message);
return false;
}
}
}
if (document.layers)
{
document.captureEvents(Event.MOUSEDOWN);
document.onmousedown = clickNS4;
}
else if (document.all
&& !document.getElementById) {
document.onmousedown = clickIE4;
}
document.oncontextmenu = new Function("return false")
</script>
</head>
0 comments:
Post a Comment