[X]

The Other Event Model

browser wars 1997 partly

Internet Explorer's whole rival event system: attachEvent to listen, a global window.event, srcElement, and returnValue = false.

In 2026: Partly, and the surviving parts are a scandal. attachEvent is long gone, IE11 dropped it in 2013. But window.event, srcElement and returnValue all still work in Chromium in 2026, kept alive because too many old handlers would break, so the demo's handler reads the global and succeeds. Firefox held out against window.event until 2018, then gave in.

Where it came from: Microsoft Internet Explorer 4 event model, 1997, the other half of the browser war that addEventListener settled. MDN

<button id="box">Click me</button>
<p id="out"></p>

<script language="JavaScript">
function handler() {
  var e = window.event;      // the global. No argument needed!
  document.getElementById("out").innerHTML =
      "window.event still works. srcElement says: " + e.srcElement.tagName;
  e.returnValue = false;     // IE for preventDefault
}
var box = document.getElementById("box");
if (box.attachEvent) box.attachEvent("onclick", handler);  // the IE way
else box.onclick = handler;                                // everyone else
</script>
sandboxed demo · breaks nothing but itselfrestart

More in browser wars

all 19 in browser wars › · the whole library ›