如何使用javascript禁用ctrl + a?

Vig*_*ani 0 html javascript wordpress

<script type="text/javascript">

function mischandler(){
return false;
}

function mousehandler(e){
var myevent = (isNS) ? e : event;
var eventbutton = (isNS) ? myevent.which : myevent.button;
if((eventbutton==2)||(eventbutton==3)) return false;
}
document.oncontextmenu = mischandler;
document.onmousedown = mousehandler;
document.onmouseup = mousehandler;
var isCtrl = false;
    document.onkeyup=function(e)
    {
    if(e.which == 17)
    isCtrl=false;
    }

    document.onkeydown=function(e)
    {
    if(e.which == 17)
    isCtrl=true;
    if((e.which == 85) || (e.which == 67) && isCtrl == true)
    {
    // alert(‘Keyboard shortcuts are cool!’);
    return false;
    }
    }

</script>
Run Code Online (Sandbox Code Playgroud)

大家好,我使用代码禁用右键单击,以及ctrl+ cctrl+ u如何禁用ctrl a以下代码.任何帮助都会很棒.

谢谢,薇薇

Wha*_*ied 15

你不应该试着这样做,让我告诉你为什么.我假设您要禁用ctrl+ c因为您不希望用户能够从您的网站复制内容,您是否考虑过有十几种其他方式来复制您的内容?

  1. 下载html文件并在他们喜欢的文本编辑器中复制
  2. 检查元素并从那里复制内容
  3. 使用鼠标右键单击 - >复制

而对于我的好朋友@glenatron:

  1. 网络嗅探器就像浏览器和网卡之间的Fiddler一样
  2. 截图,拍摄显示器的照片

......这个清单一直在继续.

此外,试图阻止用户正常使用功能只会打扰并惹恼他们; 最有可能导致他们离开您的网站,永远不会返回.


Kis*_*tel 5

下面的代码用于检测ctrl + a,ctrl + A,ctrl + c,ctrl + C,ctrl + u,ctrl + U和你的代码编辑.

<script type="text/javascript">
var isNS = (navigator.appName == "Netscape") ? 1 : 0;

if(navigator.appName == "Netscape") document.captureEvents(Event.MOUSEDOWN||Event.MOUSEUP);

function mischandler(){
return false;
}

function mousehandler(e){
var myevent = (isNS) ? e : event;
var eventbutton = (isNS) ? myevent.which : myevent.button;
if((eventbutton==2)||(eventbutton==3)) return false;
}
document.oncontextmenu = mischandler;
document.onmousedown = mousehandler;
document.onmouseup = mousehandler;
var isCtrl = false;
document.onkeyup=function(e)
{
if(e.which == 17)
isCtrl=false;
}

document.onkeydown=function(e)
{
if(e.which == 17)
isCtrl=true;
if(((e.which == 85) || (e.which == 117) || (e.which == 65) || (e.which == 97) || (e.which == 67) || (e.which == 99)) && isCtrl == true)
{
// alert(‘Keyboard shortcuts are cool!’);
return false;
}
}
Run Code Online (Sandbox Code Playgroud)

你可以从下面的链接获得密钥的价值

http://help.adobe.com/en_US/AS2LCR/Flash_10.0/help.html?content=00000520.html 享受...... !! :)