Home > Javascript > Disable Right Click

Disable Right Click


Hi

Copy and Paste it into your Source Code

<script language=JavaScript>

var message="Disabled!";

function clickIE(){
if (event.button==2){
alert(message);
return false;
}
}

function clickNS(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=clickNS;
}
else if (document.all&&!document.getElementById){
document.onmousedown=clickIE;
}

document.oncontextmenu=new Function("alert(message);return false")

// -->
</script>

//———Or—————

<script language="javascript">
document.onmousedown=disableclick;
status="Right Click Disabled";
Function disableclick(e)
{
  if(event.button==2)
   {
     alert(status);
     return false; 
   }
}
</script>
<body oncontextmenu="return false">
...
</body>

———-or——-

<Body>
  <Table>
   <tr oncontextmenu="return false">
    <td>
     <asp:datagrid id="dgGrid1">---</asp:datagrid>
   </td>
  </tr>
 </Table>
</Body>

Good Luck

Advertisements
Categories: Javascript
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: