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 6.0/7.0/8.0+, FireFox 2.0/3.0, Safari/Chrome

ADDITIONAL ONLINE RESOURCES:

  1. How to select web browser and check its capabilities
  2. Computer mouse triple-click is a convenient feature
Project contains:
1. Javascript module (rightClick.js)
2. Sample ASP.NET Web page (Default.aspx) to demonstrate the functionality
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 PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<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>

ADDITIONAL ONLINE RESOURCES:

  1. Rich internet applications, part 1: embedding YouTube™ video player into web page
  2. Rich internet applications, part 2: Silverlight™ media player
  3. Rich internet applications, part 3: HTML 5 video player
  4. How to select web browser and check its capabilities
  5. How to archive and back-up your online content
  6. Computer mouse triple-click is a convenient feature
  7. How to use online geocoders and interactive maps
  8. Search engine optimization and online concordance calculator

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

Last edited Aug 28, 2010 at 4:03 PM by DrABELL, version 7