Disable Right Click in website

不打扰是莪最后的温柔 提交于 2019-12-23 04:52:06

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!