JS prohibits copying web page code

Source: Internet
Author: User
Keywords Web page production Ajax javascript
Tags ajax button close code document function html http

JS prohibits copying web page code
<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
<html xmlns= "http://www.jzread.com/1999/xhtml" >
<head>
<meta http-equiv= "Content-type" content= "HTML; charset=gb2312 "/>
<title>js prohibit copying of Web page code </title>
<script type= "Text/javascript" >
Document.body.oncopy = nocopy;

function Nocopy () {
Clipboarddata.setdata ("Text", "");
SetTimeout (nocopydelay,100);
}
function Nocopydelay () {
Alert ("Cannot copy");
Clipboarddata.setdata ("text", "haha" + "rn" article from: jzread.com detailed reference: "+location.href);"
}

Method Two

Function rf ()
    {return false;}
    document.oncontextmenu = RF
    function KeyDown ()
    { if (Event.ctrlkey ==true | | event.keycode ==93 | | Event.shiftkey ==true) {return false;}}
    document.onkeydown =keydown
    function drag ()
    { return false;
    Document.ondragstart=drag
    function Stopmouse (e) {
     if (navigator.appname = ' Netscape ' && (E.which = 3 | | e.which = 2))
    return false;
    else if
    (navigator.appname = = ' Microsoft Internet Explorer ' && ( Event.button = 2 | | Event.button = = 3)) {
   //alert ("");
    return false;
   }
    return true;
   }
    Document.onmousedown=stopmouse;
    if (document.layers)
    window.captureevents (event.mousedown);
    Window.onmousedown=stopmouse;
</script>

</head>
<script language= "JavaScript"
<!--
Function key () {
if (Event.shiftkey) {
Window.close ();}
//Disable Shift
if (event.altkey) {
Window.close ();}
//No ALT
if (event.ctrlkey) {
Window.close ();}
//Prevent CTRL
return false;
Document.onkeydown=key;
If window. Event)
Document.captureevents (event.mouseup);
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;
}
//Right-button
Document.oncontextmenu = nocontextmenu;  //for ie5+
Document.onmousedown = norightclick;  //For all others
//-->
</script>
<body onselectstart= ' return false '; Onpaste= "return false";>
JS prohibitedCopy Web page code
</body>
</html>
 

Related Article

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.