Saturday, 31 August 2013

How do I disable right click on my web page,javascript - disable right click on webpage

Hi Friends, in this article I will explain about How to disable right click on Web page using JavaScript.
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.
There are several ways a user can still copy the contents on your website. If they decide to disable the JavaScript on their web browser, they will be able to access your contents, with or without the right-click. Hence, I would strongly suggest you edit the copyright close on your pictures as well as your contents.
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

© 2012-2018 Aspdotnet-Kishore.blogspot.com. All Rights Reserved.
The content is copyrighted to Kishore and may not be reproduced on other websites without permission from the owner.