The Internet Explorer Event Model: The Event Object - Doc JavaScript | WebReference

The Internet Explorer Event Model: The Event Object - Doc JavaScript

The Event Object

Internet Explorer 4.0x's event object is similar to the one in Navigator 4.0x. However, there are many differences between the two implementations.

The event object in Internet Explorer 4.0x is available only during an event. Therefore, you can only refer to it in event handler scripts and event processing functions. The event object is governed by the window object, so its formal syntax is window.event. The preceding window specification is not necessary in any version of JavaScript, so it may be omitted.

The event object represents the state of the event that is associated with the object at a given time, such as the element where the event occurred and the location of the mouse cursor.

The following example displays the current position of the mouse cursor (with respect to the browser window) in the status bar:

function displayLocation() {
  var str = "";
  str += "X=" + window.event.clientX;
  str += ", ";
  str += "Y=" + window.event.clientY;
  window.status = str; // display in status bar
document.onmousemove = displayLocation;
// -->

If you're using Internet Explorer 4.0x, you've probably already noticed the running numbers in the status bar. We'll discuss the cross-browser version for this script and others in our next column, covering the "cross-browser event model."

Created: December 30, 1997
Revised: December 30, 1997