Disable right click with Javascript
By Anuraj P on April 18th, 2007 . No Comments .
Javascript Tags: Context Menu, Disable Context Menu, HTML, Javascript
Here is two javascript code, helps you to disable right click, on webpages with Javascript.
function NoRightClick() {
if (event.button == 2)
{
alert("This action is not possible")
}
}
document.onmousedown=NoRightClick;
Or you can simply use.
<body oncontextmenu="return(false);">
This second code works only in Microsoft Internet Explorer.
Search
categories
- Code coverage (1)
- Uncategorized (4)
- Version Control (8)
- Unit Testing (14)
- SQL Server (16)
- sharepoint (18)
- Windows 7 (19)
- User Group Activities (27)
- Javascript (33)
- ASP.Net (60)
- Windows Forms (62)
- Visual Studio (67)
- Miscellaneous (69)
- .Net 3.0 / 3.5 (149)
- .Net (272)
- Office Interoperability (4)
- ASP.Net MVC (5)
- WCF (8)
- Silverlight (15)
- Win 32 API (17)
- WPF (29)
- .Net 4.0 (62)
Copyright © 2007-2012 dotnet thoughts
Powered by GoIsha.com.