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

posted @ 2012-05-12 21:53  小草旁的大树  阅读(782)  评论(0编辑  收藏  举报