Disable Right Click in Browsers
Author:Mudassar Khan
Below is the JavaScript Snippet to disable Right Click in Browsers.
<script type = "text/javascript">
function mousedown()
{
return false;
}
function mouseup(e)
{
if(e != null && e.type == "mouseup")
{
if (e.which==2||e.which==3)
{
return false;
}
}
}
function contextMenu()
{
return false;
}
if (document.layers)
{
document.captureEvents(Event.MOUSEDOWN);
document.onmousedown=mousedown;
}
else
{
document.onmouseup=mouseup;
}
document.oncontextmenu=contextMenu;
</script>
This page is also using the above script for Disabling Right Click.
It has been tested for the following Browsers.
1. Internet Explorer 7
2. Firefox 3
3. Google Chrome
You can download the sample source code here
DisableRightClick.zip (1.18 kb)