Javascript Disable Right Click (JDRC)

If we often create Web Application Programs, of course Javascript Programming is needed to do the initial processing of web pages. Here are some Javascript Tips & Tricks that are quite useful for us to use:

Sometimes we want the web page we create to not be easily viewed in the html source or properties, one simple way is to disable right click on the mouse. Here is the source program:

<html>
 <<head>
 <title> </title>
 <script language="JavaScript">

 var message="Hallo";

 ///////////////////////////////////  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")

</script>
</head>
<body>
Menonaktifkan Klik Kanan Pada Mouse
</body> </html>

When the web page is accessed, an alert box will appear when the mouse button is right-clicked, which displays an alert box with the message "Sorry, right-click doesn't work." Note: works well on IE & Mozilla browsers.


Post a Comment

Previous Next

نموذج الاتصال