Sharepoint:How to disable options cut, copy, paste, right click using JavaScript in SharePoint page
- Below is the simple jQuery code which will disable cut and copy from a web page
- Remove copy paste option you will have to disable right click
- allow the users to use the right click to copy, paste, or by using ctrl+C , ctrl+v to copy and paste
Javascript:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Disabling options 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>
</body>
</html>
<html>
<head>
</head>
<body oncopy="return false;" onpaste="return false;" oncut="return false;">
</body>
</html>
Step 1:you have to add Script Editor webpart
Step 2: Above the copy and paste your Script editor Webpart<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Disabling options 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>
</body>
</html>
<html>
<head>
</head>
<body oncopy="return false;" onpaste="return false;" oncut="return false;">
</body>
</html>
No comments:
Post a Comment