Disabling the Context Menu - DHTML Lab - DHTML Diner | 3 | WebReference

Disabling the Context Menu - DHTML Lab - DHTML Diner | 3

DHTML Diner Logo

Disabling the Context Menu



Explorer for Macintosh

As mentioned, Explorer for the Macintosh regards the context menu to be connected to the mousedown event. We also saw that any element can have the context menu disabled by returning false from its mousedown event. Unlike Navigator, Explorer allows the mousedown event for all elements, with very few exceptions, so authors have many more options for page customization, as regards the context menu.

To turn off the context menu for all elements in a page, IE for Macintosh requires only a function to be assigned to the document's event handler!

document.onmousedown = function(){}

The above suffices, although for good form we should enter a return value:

document.onmousedown = function(){return false}

Note:
The above will turn off the context menu for all elements. If you want to turn it off for a few elements only, then apply mousedown handlers to those elements only.

But, what about Explorer for Windows?


Produced by Peter Belesis and

All Rights Reserved. Legal Notices.
Created: April 28, 2000
Revised: April 28, 2000

URL: http://www.webreference.com/dhtml/diner/contextmenu/3.html