//方法一
document.oncontextmenu = function(){
return false;
};
//方法二 不支持 IE < 9
window.addEventListener('contextmenu', function(e){
e.preventDefault();
}, false);
通常输入框不禁用
document.oncontextmenu = function (event){
if(window.event){
event = window.event;
}
try{
let the = event.srcElement;
if (!((the.tagName == "INPUT" && the.type.toLowerCase() == "text") || the.tagName == "TEXTAREA")){
return false;
}
return true;
} catch (e){
return false;
}
}