JS禁止右击菜单、复制、选择


function key(){
if(event.shiftKey){
window.close();}
//禁止Shift
if(event.altKey){
window.close();}
//禁止Alt
if(event.ctrlKey){
window.close();}
//禁止Ctrl
return false;}
document.onkeydown=key;

 

function nocontextmenu(){
//alert("a");
try{
event.cancelBubble = true
event.returnValue = false;
}catch(e){

}
return false;
}

function norightclick(){
if (event.button == 2 || event.button == 3){
//alert("a");
try{
event.cancelBubble = true
event.returnValue = false;
}catch(e){

}
return false;
}
}


document.oncontextmenu = nocontextmenu; // for IE5+
document.onmousedown = norightclick; // for all others

document.onselectstart = function(){
return false;
}
document.ondragstart = function(){
return false;
}

 

 

转自:http://dingjun1.iteye.com/blog/227556

你可能感兴趣的:(js)