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

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

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

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

function iEsc(){ return false; }
function iRec(){ return true; }
function DisableKeys() {
if(event.ctrlKey || event.shiftKey || event.altKey) {
window.event.returnValue=false;
iEsc();}
}
document.ondragstart=iEsc;
document.onkeydown=DisableKeys;
document.oncontextmenu=iEsc;
if (typeof document.onselectstart !="undefined")
document.onselectstart=iEsc;
else{//camnpr.com
document.onmousedown=iEsc;
document.onmouseup=iRec;
}
//禁止右键
function DisableRightClick(www_camnpr_com){
if (window.Event){
if (www_camnpr_com.which == 2 || www_camnpr_com.which == 3)
iEsc();}
else if (event.button == 2 || event.button == 3){
event.cancelBubble = true
event.returnValue = false;
iEsc();}
}
365据说看到好文章不转的人,服务器容易宕机
原创文章如转载,请注明:转载自郑州网建-前端开发 http://camnpr.com/
本文链接:http://camnpr.com/javascript/nocopy.html