function block(e){
if(window.event){
e=window.event;
e.returnValue = false;
}else
e.preventDefault();
}
document.oncontextmenu = block;
點擊鼠標右鍵會觸發contextmenu事件,如果希望徹底屏蔽鼠標右鍵,最好的方法是屏蔽document的contextmenu事件。
IE中對應的屬性是returnValue
DOM瀏覽器對應的屬性是preventDefault()方法。