0

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") 
tckmn
  • 57,719
  • 27
  • 114
  • 156
Coderwannabe
  • 407
  • 1
  • 5
  • 11

2 Answers2

2

Just remove the alert:

if (event.button==2){ return false; } } 
AlienWebguy
  • 76,997
  • 17
  • 122
  • 145
-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>
  • 1
    This is wrong, bad practise ("script language=JavaScript"), code-only and does not even (!) answer the question. Grammar is wrong too. – Léo Lam Jul 09 '14 at 21:22
  • 1
    Hi Leo Lam you I don't think so to tell the KG'S put in the and the above code just try it in any html and feel the difference – Mekebib Tadesse Jul 09 '14 at 21:55
  • 1
    Have you really tested it or read the question? Your code still has an `alert()` call in it. Read the question and your code again. – Léo Lam Jul 10 '14 at 10:53