Saturday, November 26, 2011

Disabling right click/Cut/Copy/Paste into HTML form using Javascript | Disable view Source

Disabling right click/Cut/Copy/Paste into HTML form using Javascript | Disable view Source:
In this article,I will explain  how to Disable cut, copy, paste, right click and context menu using Javascript.Some times we need to disable the right click option in the web browser for security
reason.Disable view source is the Best way to prevent content hijacking.You can Protect images,content by disabling right-click on a web page..with below script you can disable right click in the entire page using Javascript.

Example:Disabling right click/Cut/Copy/Paste into HTML form
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Disabling cut, copy, paste, right click and context menu using Javascript </title>
<script type="text/javascript"> 
//below javascript is used for Disabling right-click on HTML page
document.oncontextmenu=new Function("return false");//Disabling right-click


//below javascript is used for Disabling text selection in web page
document.onselectstart=new Function ("return false"); //Disabling text selection in web page
if (window.sidebar){
document.onmousedown=new Function("return false"); 
document.onclick=new Function("return true") ; 


//Disable Cut into HTML form using Javascript 
document.oncut=new Function("return false"); 


//Disable Copy into HTML form using Javascript 
document.oncopy=new Function("return false"); 


//Disable Paste into HTML form using Javascript  
document.onpaste=new Function("return false"); 
}
</script>
</head>
<body>
how to Disable cut, copy, paste, right click and context menu using Javascript 
</body>
</html>


Example2:Disable Cut,Copy,Paste into HTML form using Javascript 
<html>
<head>
</head>
<body oncopy="return false;" onpaste="return false;" oncut="return false;">
        <div>
          Disabling cut, copy, paste, right click using Javascript     
       </div>
   </body>
</html>

No comments:

Post a Comment