Javascript 我想禁用firefox和IE中的右键单击选项

Javascript 我想禁用firefox和IE中的右键单击选项,javascript,jquery,internet-explorer,firefox,mozilla,Javascript,Jquery,Internet Explorer,Firefox,Mozilla,根据我的要求,我有一个PDF文件显示给用户。但用户不应该能够保存它。因此,我需要禁用浏览器的右键单击选项。它在Chrome中工作得很好,但在Mozilla FF或IE中却不起作用 if (document.layers) { document.captureEvents(Event.MOUSEDOWN); document.onmousedown = function () { return false; }; } else { document.onmouseu

根据我的要求,我有一个PDF文件显示给用户。但用户不应该能够保存它。因此,我需要禁用浏览器的右键单击选项。它在Chrome中工作得很好,但在Mozilla FF或IE中却不起作用

if (document.layers) { 
    document.captureEvents(Event.MOUSEDOWN); 
    document.onmousedown = function () { return false; }; 
} else { 
    document.onmouseup = function (e) { 
        if (e != null && e.type == "mouseup") { //Check the Mouse Button which is clicked. 
            if (e.which == 2 || e.which == 3) { //If the Button is middle or right then disable. 
                return false; 
            } 
        } 
    }; 
} 
document.oncontextmenu = function () { return false; };
这是我的代码,它在Chrome中运行良好,但在FF或IE中不起作用

if (document.layers) { 
    document.captureEvents(Event.MOUSEDOWN); 
    document.onmousedown = function () { return false; }; 
} else { 
    document.onmouseup = function (e) { 
        if (e != null && e.type == "mouseup") { //Check the Mouse Button which is clicked. 
            if (e.which == 2 || e.which == 3) { //If the Button is middle or right then disable. 
                return false; 
            } 
        } 
    }; 
} 
document.oncontextmenu = function () { return false; };

尝试此代码

function clickIE() {
    if (document.all) {  //document.all specific to Internet Explorer  
        return false;
    }
}
function clickAll(e) {
    if (document.layers || (document.getElementById && !document.all)) {  //document.layers specific to Netscape
        if (e.which == 2 || e.which == 3) {
            return false;
        }
    }
}
if (document.layers) {
    document.captureEvents(Event.MOUSEDOWN);
    document.onmousedown = clickAll;
} else {
    document.onmouseup = clickAll;
    document.oncontextmenu = clickIE;
}

document.oncontextmenu = new Function("return false")

不用麻烦,用户总是有办法保存文件的,你就是无法阻止它。if(document.layers){document.captureEvents(Event.MOUSEDOWN);document.onmousedown=function(){return false;};}else{document.onmouseup=function(e){if(e!=null&&e.type==“mouseup”){//检查单击的鼠标按钮。如果(e.which==2 | | e.which==3){//如果按钮位于中间或右侧,则禁用.return false;}}}}};}document.oncontextmenu=函数(){return false;};