Inhaltsverzeichnis reduzieren
Inhaltsverzeichnis erweitern
Dieser Inhalt ist in Ihrer Sprache leider nicht verfügbar. Im Folgenden finden Sie die englische Version.

event object

Represents the state of an event, such as the element in which the event occurred, the state of the keyboard keys, the location of the mouse, and the state of the mouse buttons.

Document Object Model (DOM) Level 2 HTML Specification, Section 1.6.5



The event object has these types of members:


The event object has these properties.



This property is not supported for Windows Store apps using JavaScript.


Gets a value that indicates whether the Alt key is pressed.


This property is not supported for Windows Store apps using JavaScript.


Sets or retrieves whether the current event should bubble up the hierarchy of event handlers.


Returns a reference to the constructor of an object.


Retrieves a value that indicates whether the document contains additional content after processing the current LayoutRect object.


Gets a value that indicates whether the Ctrl key is pressed.


Sets or retrieves the data column affected by the oncellchange event.


Standards information


The event object is available only during an event—that is, you can use it in event handlers but not in other code.

Although all event properties are available to all event objects, some properties might not have meaningful values during some events. For example, the fromElement and toElement properties are meaningful only when processing the onmouseover and onmouseout events.

Several of the properties that apply to this object are not writable unless this object has been created using the createEventObject method. The following is a list of these properties: altKey, altLeft, button, clientX, clientY, ctrlKey, ctrlLeft, dataFld, offsetX, offsetY, propertyName, qualifier, reason, repeat, screenX, screenY, shiftKey, shiftLeft, srcUrn, type, x, and y.


This example uses the event object to check whether the user clicked the mouse within a link, and to prevent the link from being navigated if the SHIFT key is down. It also display mouse position within the <body> element:

<!DOCTYPE html>

  <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
  <title>Cancels Links</title>
    body {
      border: 1px black solid;
      width: 32em;
      padding: 0 1em;

<body id="bodyTag">
  <p>Mouse over this black box (i.e., the &lt;body&gt; element) to see mouse 
  <p>And click <a href="" target="_blank">this</a> link with and without holding the SHIFT key down.</p>
  <p id="mousePositionDisplay">Mouse position:</p>
    var bodyElement = document.getElementById('bodyTag');
    bodyElement.addEventListener('click', cancelLink, 'false');
    bodyElement.addEventListener('mousemove', reportMousePosition, 'false');
    function cancelLink() {
      if (window.event.srcElement.tagName == "A" && window.event.shiftKey) {
        window.event.returnValue = false;
    function reportMousePosition() {
      document.getElementById('mousePositionDisplay').innerHTML = "Mouse position: (" + window.event.x + ", " + window.event.y + ")";




© 2016 Microsoft