前端项目通用、常用js common.js

  1 var url = location.href;
  2 
  3 if (url.toLowerCase().indexOf("/akweb_admin/") == -1) {
  4 
  5     function Click() {
  6 
  7         if (event.button != 1) {
  8 
  9             event.returnValue = false;
 10 
 11         }
 12 
 13     }
 14 
 15     document.onmousedown = Click;
 16 
 17  
 18 
 19     function key(e) {
 20 
 21         ////禁止Shift
 22 
 23         //if(event.shiftKey){
 24 
 25         //    return false;
 26 
 27         //}
 28 
 29         //禁止Alt
 30 
 31         if (event.altKey) {
 32 
 33             return false;
 34 
 35         }
 36 
 37         //禁止Ctrl
 38 
 39         if (event.ctrlKey) {
 40 
 41             return false;
 42 
 43         }
 44 
 45         return true;
 46 
 47     }
 48 
 49     //禁止键盘
 50 
 51     document.onkeydown = key;
 52 
 53  
 54 
 55     //if (window.Event)
 56 
 57     //document.captureEvents(Event.MOUSEUP);
 58 
 59  
 60 
 61     function nocontextmenu() {
 62 
 63         event.cancelBubble = true
 64 
 65         event.returnValue = false;
 66 
 67         return false;
 68 
 69     }
 70 
 71     function norightclick(e) {
 72 
 73         if (window.Event) {
 74 
 75             if (e.which == 2 || e.which == 3)
 76 
 77                 return false;
 78 
 79         }
 80 
 81         else
 82 
 83             if (event.button == 2 || event.button == 3) {
 84 
 85                 event.cancelBubble = true
 86 
 87                 event.returnValue = false;
 88 
 89                 return false;
 90 
 91             }
 92 
 93     }
 94 
 95     //禁右键
 96 
 97     document.oncontextmenu = nocontextmenu;  // for IE5+
 98 
 99     document.onmousedown = norightclick;  // for all others
100 
101     //禁止选取
102 
103     //document.onselectstart = function () { return false; }
104 
105     //禁止粘贴
106 
107     document.onpaste = function () { return false; }
108 
109     //禁止复制
110 
111     document.oncopy = function () { return false; }
112 
113     //禁止剪切
114 
115     document.oncut = function () { return false; }
116 
117 }

 

posted @ 2016-12-25 17:42  haonanElva  阅读(635)  评论(0编辑  收藏  举报