Disabling the mouse right click : JavaScript

ImageAs mention in the title here is code to disable the right click for the mouse in the browser (tested in IE ).
The code is JavaScript ,the code is readable and can be used to handle other mouse events.
just call DisableRightclick() once in your page.

[script language=”javascript” ]
var IE;
var NN;
function right(click)
{
if(IE && (event.button==2 || event.button==3))
{
alert(“The right click has been disabled here.”);
return false;
}

if(NN && (click.which==2 || click.which==3))
{
alert(“The right click has been disabled here.”);
return false;
}

return false;
}

function DisableRightclick()
{

if(navigator.appName==”Microsoft Internet Explorer”)
{
IE=true;
}

if(navigator.appName==”Netscape”)
{
NN=true;
}

if (document.layers) window.captureEvents(Event.MOUSEDOWN);
if (document.layers) window.captureEvents(Event.MOUSEUP);
document.onmousedown=right;
document.onmouseup=right;
window.document.layers=right;
}
[/script]

Advertisements

About amr2008

Welcome there, Amr Abdel-Aziz, CEO Founder, Ultras Business "لنكن التغيير الذي نريد أن نراه فى العالم"

Posted on February 5, 2013, in Uncategorized. Bookmark the permalink. Leave a comment.

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: