On this page I give some quick event compatibility tables.
This page is meant for a fast overview of the most common event properties. If you want to study the complete list, see the W3C DOM Compatibility - Events page.
Event registration models
How do I add event handlers to an HTML element?
||Early event handlers||Yes, even in Version 2 and 3 browsers||Completely cross-browser compatible, so I advise you to use one of these models.||Traditional:
||No||6||Yes||7||No||The most advanced model, unfortunately too little supported.|
||5+ Win||No||No||Strongly deprecated|
Event accessing models
How do I access the event when I want to obtain more information?
||Event accessing||No||Yes||Yes||Support detection necessary.|
If an element and one of its ancestors have an event handler for the same event, which one should fire first?
||Event order||No||Yes||7||No||Netscape 4 supports only event capturing. In the other browsers use of the W3C model is required for capturing|
||Yes||6||Yes||Default event order in all browsers but Netscape 4.|
|What is the type of the event?||type||Event properties||Yes||Incredible but true: this property works correctly in all browsers!|
|Which HTML element is the target of the event?||target||Event properties||Mac||Yes||Although the event may bubble upwards, the target/ srcElement remains
the actual element the event took place on.
|currentTarget||Event order||No||6||Yes||No||Refers to the HTML element that the event is currently handled by.
There is no similar Microsoft property.
For mouseovers the
For mouseouts the
|Which key was pressed during the event?||keyCode||Event properties
||Yes||6||Yes||Yes||No||The 'a' key has value 65, except on NN4 where it has 97
You can get the character by
|Which special key was pressed during the event?||shiftKey, altKey, ctrlKey||Not treated||Yes||6||Yes||No||These three properties become true when the appropriate special key is pressed.
|modifiers||No||4||No||Values: 1: Alt, 2: Ctrl, 4: Shift, 8: Command
|Which mouse button was pressed during the event?||which
||Event properties||No||Yes||No||Only left button||No||Reading out the button is only possible with
If the mouse has been configured for left-handed use the left and right buttons change place
On Mac there is only one button. Nonetheless Netscape 6 counts a Ctrl-Click as a right-click.
|What was the mouse position during the event?||clientX, clientY||See my Evolt article||Yes||6||non–standard (but the standard itself is wrong)||pageX/Y reliably give the coordinates relative to the document.
clientX/Y is a godawful mess.
|screenX, screenY||Event properties||Yes||This pair gives the mouse coordinates relative to the entire computer screen.|
|x, y||Not studied||Yes||4||No||7
||Yes||Didn’t study these properties, except to ascertain that they don’t contain a solution for our problem.|