Microsoft HomeproductssearchsupportshopWrite Us   Microsoft Home
Magazine
 |  Community
 |  Workshop
 |  Tools & Samples
 |  Training
 |  Site Info

Workshop  |  DHTML, HTML & CSS

oncontextmenu Event


This document describes technologies available in the Internet Explorer 5 Beta. While we encourage you to evaluate these features and to send us your feedback, please note that these features are subject to change.

Fires when the user clicks the right mouse button in the client area.

Syntax

Inline HTML<ELEMENT oncontextmenu = "handler" ... >All platforms
Event propertyobject.oncontextmenu = handlerJScript™ (compatible with ECMA 262 language specification) only
Named script<SCRIPT FOR=object EVENT=oncontextmenu>Microsoft® Internet Explorer only

Remarks

BubblesYes
CancelsYes
To invoke Right-click the object.
Default action Opens the context menu. To cancel the default behavior, set the returnValue property of the event object to FALSE.

Event Object Properties

Although event handlers in the DHTML Object Model do not receive parameters directly, the handler can query the event object for data.

Event Object Properties

altKeyRetrieves the current state of the ALT key.
cancelBubbleSets or retrieves whether the current event should bubble up the hierarchy of event handlers.
clientXRetrieves the x-coordinate of the position of the cursor when the mouse is clicked, relative to the size of the client area of the window but excluding window decorations or scroll bars.
clientYReturns the y-coordinate of the position of the cursor when the mouse is clicked, relative to the size of the client area of the window but excluding window decorations or scroll bars.
ctrlKeyRetrieves the state of the CTRL key.
offsetXRetrieves the horizontal coordinate of the mouse's position relative to the object firing the event.
offsetYRetrieves the vertical coordinate of the mouse's position relative to the object firing the event.
returnValueSets or retrieves the return value from the event.
screenXRetrieves the horizontal position of the mouse, in pixels, relative to the user's screen.
screenYRetrieves the vertical position of the mouse, in pixels, relative to the user's screen.
shiftKeyRetrieves the state of the SHIFT key.
srcElementRetrieves the object that fired the event.
typeRetrieves the event name from the event object.
xReturns the horizontal position of the mouse when the event fires.
yReturns the vertical position of the mouse when the event fires.

Example

The example demonstrates the oncontextmenu event handlers for the document.

Sample Code

<SCRIPT FOR = document EVENT = oncontextmenu>
   document.oncontextmenu = fnContextMenu;
</SCRIPT>

<SCRIPT>
function fnContextMenu(){
   event.returnValue = false;
}
</SCRIPt>

This feature requires Internet Explorer 4.0 or later. Click the icon below to install the latest version. Then reload this page to view the sample.
Microsoft Internet Explorer

Applies To


Does this content meet your programming needs? Write us!

Back to topBack to top

© 1998 Microsoft Corporation. All rights reserved. Terms of use.

 

Magazine Home
Ask Jane
DHTML Dude
Extreme XML
For Starters
More or Hess
Servin' It Up
Site Lights
Web Men Talking
Member Community Home
Benefits: Freebies & Discounts
Benefits: Promote Your Site
Benefits: Connect with Your Peers
Benefits at a Glance
Online Special-Interest Groups
Your Membership
SBN Stores
Join Now
Workshop Home
Essentials
Content & Component Delivery
Component Development
Data Access & Databases
Design
DHTML, HTML & CSS
Extensible Markup Language (XML)
Languages & Development Tools
Messaging & Collaboration
Networking, Protocols & Data Formats
Reusing Browser Technology
Security & Cryptography
Server Technologies
Streaming & Interactive Media
Web Content Management
Workshop Index
Tools & Samples Home
Tools
Samples, Headers, Libs
Images
Sounds
Style Sheets
Web Fonts
Training Home
SBN Live Seminars
SBN Live Chats
Courses
Peer Support
CD-ROM Training
Books & Training Kits
Certification
SBN Home
New to SBN?
What's New on SBN
Site Map
Site Search
Glossary
Write Us
About This Site