faqts : Computers : Programming : Languages : JavaScript : Event handling

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

52 of 62 people (84%) answered Yes
Recently 9 of 10 people (90%) answered Yes


Is there a way to prevent the context menu from appearing when the right mouse button is clicked in IE4? I am aware of IE5's capability to do this.

Jul 20th, 2001 10:25
Kenneth Kephart, Martin Honnen, John Hathaway,

Actually on ie5, and not sure in ie4, but you can place the 
oncontextmenu="return false" in the body of the html.
example: <body oncontextmenu="return false">
The above information will not produce a context menu at all.
You can popup an alert which seems to prevent the context menu
document.onmousedown =
  function () {
    if (event.button == 2) {
      alert('No context menu.');
      return false;
But think twice of that as you are heavily restricting the user gui 
without really achieving any code or images protection.
And no, there doesn't seem to be a way to avoid the context menu in IE4 
without popping up the alert.