防止用户使用jQuery复制文本?

| 我如何防止用户使用jQuery复制asp.net页中的任何文本?     
已邀请:
您可以禁用右键单击,还可以在文档上绑定键事件,以检测复制命令键组合\“ Ctl + C \”并返回false。 要禁用右键单击:
jQuery(document).bind(\"contextmenu\", function(e) {
 e.preventDefault();
});
要检测Ctl + C:
jQuery(document).ready(function()
{
    var ctlPressed = false; //Flag to check if pressed the CTL key
    var ctl = 17; //Key code for Ctl Key
    var c = 67; //Key code for \"c\" key

    jQuery(document).keydown(function(e)
    {
        if (e.keyCode == ctl) 
          ctlPressed = true;
    }).keyup(function(e)
    {
        if (e.keyCode == ctl) 
          ctlPressed = false;
    });

    jQuery(\".your-no-copy-area\").keydown(function(e)
    {
        if (ctlPressed && e.keyCode == c) 
          return false;
    });
});
    
水印是您的解决方案。我可以轻松禁用Javascript。     
通常对此不屑一顾,但是如果您必须这样做,这里有一个插件     
好吧,我用了很多代码来使它像这样: 1-禁用右键单击:
<script src=\"js/jquery.min.js\" type=\"text/javascript\"></script>    
<script type=\"text/javascript\" language=\"javascript\">
    $(function () {
        $(this).bind(\"contextmenu\", function (e) {
            e.preventDefault();
            alert(\"Copy is not allowed\");
        });
    });       
</script>
2禁用选择
<script type=\"text/javascript\">

    /***********************************************
    * Disable Text Selection script- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
    * This notice MUST stay intact for legal use
    * Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
    ***********************************************/

    function disableSelection(target) {
        if (typeof target.onselectstart != \"undefined\") //IE route
            target.onselectstart = function () { return false }
        else if (typeof target.style.MozUserSelect != \"undefined\") //Firefox route
            target.style.MozUserSelect = \"none\"
        else //All other route (ie: Opera)
            target.onmousedown = function () { return false }
        target.style.cursor = \"default\"
    }

    //Sample usages
    //disableSelection(document.body) //Disable text selection on entire body
    //disableSelection(document.getElementById(\"mydiv\")) //Disable text selection on element with id=\"mydiv\"
         var alltables = document.getElementsByTagName(\“ table \”)     对于(var i = 0; i
<script type=\"text/javascript\">
     var somediv = document.getElementById(\"page-wrap\")
     disableSelection(somediv) //disable text selection within DIV with id=\"page-wrap\"
    </script>
<script type=\"text/javascript\">
    disableSelection(document.body) //disable text selection on entire body of page
</script>
现在都完成了..... 谢谢大家,这真的非常有帮助。     

要回复问题请先登录注册