问题
I have this code below to disable right click. When you hit the right click it says Function is disabled. which works but i want it to show nothing at all basicaly when you hit the right click nothing happens... what kind of magic can we use to do that?
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")
回答1:
Just remove the alert:
if (event.button==2){ return false; } }
回答2:
## 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>
来源:https://stackoverflow.com/questions/14657866/disable-right-click-in-website