禁用Ctrl + A,Ctrl + C键功能到HTMl页面

Nav*_*yah 1 html javascript keyboard

如何禁用整个页面的Ctrl+ Actrl+ C键?我想从键盘上禁用复制,粘贴功能.我找到了一些只禁用一个文本框的链接.但我想禁用ctrl整个HTML页面的功能.

我在标签中粘贴了以下代码并添加了disablePagebody onload 函数.

<!DOCTYPE html>
<html lang="en">
<head>
    <title>html2canvas example</title>
 <script type="text/javascript" src="img/html2canvas.js"></script>
<script language=JavaScript>
function ieClicked() {
    if (document.all) {
        return false;
    }
}
function firefoxClicked(e) {
    if(document.layers||(document.getElementById&&!document.all)) {
        if (e.which==2||e.which==3) {
            return false;
        }
    }
}
if (document.layers){
    document.captureEvents(Event.MOUSEDOWN);
    document.onmousedown=firefoxClicked;
}else{
    document.onmouseup=firefoxClicked;
    document.oncontextmenu=ieClicked;
}
document.oncontextmenu=new Function("return false")
function disableselect(e){
    return false
    }
    function reEnable(){
    return true
    }
    document.onselectstart=new Function ("return false")
    if (window.sidebar){
    document.onmousedown=disableselect
    document.onclick=reEnable
    }
</script>
    <style>
    canvas{border:1px solid #222}
    </style>     
</head>
<body>
   <a class="upload"  >Upload to Imgur</a>  
   <a href="#" download="canvasexport.pdf" onclick="window.print()" ><img src="images/print-icon.png" alt="Print" width="16" height="16" ></a>

   <a href="#" id="download" download="diversio.pdf" onclick="printImg();"> 
   <img src="images/print-icon.png" alt="Print" width="16" height="16" >
   </a> 

    <h2>this is <b>bold</b> <span style="color:red">red</span></h2>   
    <p> Feedback form with screenshot This script allows you to create feedback forms which include a screenshot, 
    created on the clients browser, along with the form. 
    The screenshot is based on the DOM and as such may not be 100% accurate to the real 
    representation as it does not make an actual screenshot, but builds the screenshot based on the 
    information available on the page. How does it work? The script is based on the html2canvas library,
     which renders the current page as a canvas image, by reading the DOM and the different styles applied 
     to the elements. This script adds the options for the user to draw elements on top of that image, 
     such as mark points of interest on the image along with the feedback they send.
      It does not require any rendering from the server, as the whole image is created on the clients browser.
       No plugins, no flash, no interaction needed from the server, just pure JavaScript! Browser compatibility Firefox 3.5+ Newer versions of Google Chrome, Safari & Opera IE9
    </p>



</body>
</html>
Run Code Online (Sandbox Code Playgroud)

mal*_*lmX 7

试试这个:

function disableselect(e) {
    return false;
}

function reEnable() {
    return true;
}

document.onselectstart = new Function("return false");

if (window.sidebar) {
    document.onmousedown = disableselect;
    document.onclick = reEnable;
}
Run Code Online (Sandbox Code Playgroud)

将其放在您的<head>标签中,用户无法在您的页面上选择文字.但是,无法保证您的内容无法被盗.上述JavaScript可以被体验互联网用户轻松绕过.例如,如果禁用了浏览器的JavaScript,则代码将无法运行.工作副本可在此处获得.