Today met a customer request page can not be copied requirements, search in Baidu, get the following answer, very good, with notes down
Thank you very much for sharing the great gods of the network, and for spreading this spirit.
Disable copying of Web page content with Java <script language=javascript>
Function key () {
if (Event.shiftkey) {
Window.close ();}
Disable shift
if (Event.altkey) {
Alert (' Prohibit ctrl-c copy of this paste content ');}
Suppress Alt
if (Event.ctrlkey) {
Alert (' Prohibit ctrl-c copy of this paste content ');}
Suppress CTRL
return false;}
Document.onkeydown=key;
if (window. Event)
Document.captureevents (Event.mouseup);
Swordmaple JavaScript article.
From www.XXXX.com
function Nocontextmenu () {
Event.cancelbubble = True
Event.returnvalue = false;
return false;}
function Norightclick (e) {
if (window. Event) {
if (E.which = = 2 | | e.which = = 3)
return false;}
Else
if (Event.button = = 2 | | event.button = = 3) {
Event.cancelbubble = True
Event.returnvalue = false;
return false;}
}
function Click () {
Alert (' Prohibit right-pasting of this sticker ');
Window.event.returnvalue=false;
}
Document.oncontextmenu=click;
</Script>
An easier way is to add the following code to the <body> so that the left and right mouse buttons are invalidated.
topmargin= "0" oncontextmenu= "return false" ondragstart= "return false" Onselectstart = "return false" onselect= " Document.selection.empty () "oncopy=" Document.selection.empty () "onbeforecopy=" return false "onmouseup=" Document.selection.empty () "
1. Prevent web pages from being saved as: Add the following code after <body>:
<noscript>
<iframe src= "*.htm" ></iframe>
</noscript>
2. Prevents Web page content from being copied. Paste: Add the following code to <body>:
<body onmousemove=\hidemenu () \ oncontextmenu= "return false" ondragstart= "return false" Onselectstart = "return False "Onselect=" Document.selection.empty () "oncopy=" Document.selection.empty () "onbeforecopy=" return false "onmouseup=" Document.selection.empty () ">
Web pages prohibit copying