Method 1
In this method we add a javascript method, in this we check if click is right click or left click if it is right click then a message is displayed like "Right click disabled"
document.onmousedown=disableclick;
status="Right Click Disabled";
Function disableclick(e)
{
if(event.button==2)
{
alert(status);
return false;
}
}
But in this solution if you click the right click it displays the message
“Right click disabled”.
If we want to remove the messegebox then this solution do not work.
I am having another simple solution to achieve the same result and also it does not show the messegebox.
Method 2
In this method we set the oncontextmenu="return false" in the body part of the page
so body part will look like
...
So whenever user clicks the right mouse button nothing will happen, no message no context menu.
Sometimes there might be requirement to disable the right click on specific control to achive this we have to follow these steps.
1. remove added code in body (i.e. oncontextmenu=”return false”)
2. Add one table and in its row add the control e.g. datagrid control
3. put the oncontextmenu=”return false” in the
So code will look like this
So by this method context menu on the right click of right mouse click can be disabled.
source: http://www.codeproject.com/Articles/11222/Disabling-the-right-click-on-web-page
0 komentar:
Posting Komentar