Web pages prohibit copying

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.