SoFunction
Updated on 2025-03-01

js prohibit page copy function disable page right-click menu example code

<body oncontextmenu="return false">Disable the right-click menu on the web page, but you can still use the shortcut keys to copy.
js code disables the copy function:
Copy the codeThe code is as follows:

<script type="text/javascript">
==function(){ return false;}
</script>

Note that this code must be placed behind the body element, and it must not work in front or in the head.
Complete: Select function on the page.
Right-click the page menu.
The page content drag function, dragging and drop can be copied. It needs to be disabled when copying is prohibited.
Page content copying function, when disabled, even if you clicked on copy or used shortcut keys, the content in your clipboard is not the content you just copied but the content you previously placed in the clipboard or is empty.
The page content cutting function has similar functions to the effect and disable copy function.
Note: When using the above disable function, if you can right-click or copy a corner of the page, it is because your body does not cover the entire page. You can add the following attributes on the body.
leftMargin=0 topMargin=0 style="width: 100%;height: 100%;"
The code to disable the copy function by setting the body attribute is as follows:
Copy the codeThe code is as follows:

<body oncontextmenu="return false" onselectstart="return false"
ondragstart="return false" oncopy="return false"
oncut="return false;
leftMargin=0
topMargin=0 style="width: 100%;height: 100%;" >
The following code is to disable the web page as Save As but my test is not successful. Who knows the reason can give a comment below, thank you.
<noscript>
<iframe scr="*.htm"></iframe>
</noscript>
</body>

js code case:
Copy the codeThe code is as follows:

//********************* Right-click on blocking ***************************
function click(e) {
if () {
if (==1||==2||==3) {
oncontextmenu='return false';
}
}
if () {
if ( == 3) {
oncontextmenu='return false';
}
}
}
if () {
();
}
=click;
= new Function("return false;")
//*******************************************
=function(evt){
if(().parentElement().type == "file"){
return false;
}
if ((==116)|| //Mask F5 Refresh Key
( && ==82)){ //Ctrl + R
=0;
=false;
}
if (()&&(==115)){ //Shield Alt+F4
return false;
}
}