1
现在,我使用此代码禁用右键点击:如何禁用某些HTML页面上点击右键有一些例外
$("body")
.attr('ondragstart', 'return false')
.attr('onselectstart', 'return false');
var message='Right click is disabled on this page!';
function clickIE4() {
if (event.button==2) {
alert(message);
return false;
}
}
function clickNS4(e) {
if (document.layers||document.getElementById&&!document.all) {
if (e.which==2||e.which==3) {
alert(message);
return false;
}
}
}
if (document.layers) {
document.captureEvents(Event.MOUSEDOWN);
document.onmousedown=clickNS4;
} else if (document.all&&!document.getElementById) {
document.onmousedown=clickIE4;
}
document.oncontextmenu = new Function('alert(message); return false');
我自己的现在,我已经实现了上下文菜单,我显示它当点击某个a
元素与类.context
。
我使用http://medialize.github.io/jQuery-contextMenu/demo.html
所以我想禁用除一个与.context
类的所有右键单击上下文菜单
您必须从某处已经没有东西像10多年来一直更新 – erikkallen
实在是禁用右键点击任何万无一失的方法复制粘贴此。任何人都可以查看您的来源并随心所欲。甚至在Firebug或其他程序中打开它并实时禁用脚本。除了激怒用户之外,它不会取得多大成就。 –
我同意,从可用性的角度来看,这是一个非常糟糕的做法。除了可能是恼人的用户之外,你绝对没有什么收获。 – luk2302