禁用网站右键单击

时间:2013-02-02 02:03:17

标签: javascript right-click disabled-control

我有以下代码禁用右键单击。当您点击右键时,它表示功能被禁用。哪个有效,但我希望它在你点击右键时没有显示任何事情没有任何反应......我们可以使用什么样的魔法来做到这一点?

var message="Function Disabled!"; 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") 

2 个答案:

答案 0 :(得分:2)

只需删除提醒:

if (event.button==2){ return false; } } 

答案 1 :(得分:-1)

## How To Disable Right Click with Out Display any thing or Var Massage  ##
<script language=JavaScript>
<!--
var message="";
function clickIE4()
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")

// --> 
</script>