Hi Friends, in this article I will explain about How to disable
right click on Web page using JavaScript.
In previous articles I explained about interview questions on SEO (Search Engine Optimization),how to remove the sessions in ASP.NET,How to remove specific session in ASP.NET,How to get second-highest salary employees in a table
Actually some people don’t want copy the data in the site at
that situation we use this.
Let us see how to disable right click on Web page using JavaScript.
First take one webpage and right the below <script>
code in the <head> tag.
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Aspdotnet-Roja:Disable
right click on website</title>
<script language="JavaScript" type
="text/javascript" >
function disablerightclick(e){
alert ("Right click not alowed to this site")
return false
}
function reEnable(){ alert ("Right click not alowed to this site")
return true
}
//if IE4+
document.onselectstart=new Function ("return
false")
document.oncontextmenu=new Function ("return
false")
//if NS6
if (window.sidebar){
document.onmousedown=disablerightclick
document.onclick=reEnable
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<h3>Aspdotnet-Roja:Disable
right click on website Using Javascript</h3>
</div>
</form>
</body>
</html>
|
Save and run the page.
When you right click on the page it will show the alert box as shown in the
below figure.
If you like my blog Aspdotnet-Roja then why are you waiting like my blog through facebook page Aspdotnet-Roja
No comments:
Post a Comment