Project Description
To make ASP.NET web-page look more "application-like" it is sometimes useful to restrict right mouse click event

Working DEMO is available at: http://www.webinfocentral.com

MOUSE_CLICK_EVENT.JPG

Browser Compatibility: IE/FireFox/Safari/Chrome

Javascript module
//******************************************************************************
// Module  :   rightClick.js
//******************************************************************************
// DISCLAIMER: This Application is provide on AS IS basis without any warranty
//******************************************************************************

var BM = 2; // button middle
var BR = 3; // button right
var msg ="MOUSE RIGHT CLICK IS NOT SUPPORTED ON THIS PAGE";

function mouseDown(e) 
{ 
  try { if (event.button==BM||event.button==BR) {return false;} }  
  catch (e) { if (e.which == BR) {return false;} } 
}
document.oncontextmenu = function() { alert(msg); return false; }
document.onmousedown   = mouseDown;
//******************************************************************************
Sample Web page (could be .html or ASP.NET Master Page)
<!DOCTYPE html">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>NO RIGHT CLICK | DEMO</title>
    <script src="rightClick.js" type="text/javascript"></script>
</head>
<body>
    <form id="form1" runat="server">
        <div>
            MOUSE RIGHT CLICK EVENT IS NOT SUPPORTED (TRY IT)...
        </div>
    </form>
</body>
</html>

 

Web Javascript ASP.NET ASP.NET 2.0 ASP.NET 3.5 HTML IE FireFox Safari Chrome Mouse Event Right Mouse Click

Last edited Feb 18 at 1:56 AM by DrABELL, version 10