禁止copy、禁止Ctrl、禁止shift、禁止alt、禁止快捷菜单、禁止右键

分类:Javascript| 发布:camnprbubuol| 查看:415 | 发表时间:2013/5/6

禁止copy、禁止Ctrl、禁止shift、禁止alt、禁止快捷菜单、禁止右键

代码如下:(建议保存到一个js文件中,例如:nocopy.js)

01function iEsc(){ return false; }
02function iRec(){ return true; }
03function DisableKeys() {
04if(event.ctrlKey || event.shiftKey || event.altKey)  {
05window.event.returnValue=false;
06iEsc();}
07}
08document.ondragstart=iEsc;
09document.onkeydown=DisableKeys;
10document.oncontextmenu=iEsc;
11if (typeof document.onselectstart !="undefined")
12document.onselectstart=iEsc;
13else{//camnpr.com
14document.onmousedown=iEsc;
15document.onmouseup=iRec;
16}
17//禁止右键
18function DisableRightClick(www_camnpr_com){
19if (window.Event){
20if (www_camnpr_com.which == 2 || www_camnpr_com.which == 3)
21iEsc();}
22else if (event.button == 2 || event.button == 3){
23event.cancelBubble = true
24event.returnValue = false;
25iEsc();}
26}
365据说看到好文章不转的人,服务器容易宕机
原创文章如转载,请注明:转载自郑州网建-前端开发 http://camnpr.com/
本文链接:http://camnpr.com/javascript/nocopy.html