handler as string
setAttribute string
setAttribute function
expando string
expando function
Results with no doctype....
IE5.5:
in head: document.documentElement set, document.body==null
onload is delivered to:
window.onload or inline body.onload (latter winning)
window.attachEvent
NOT delivered to document or documentElement
onclick is delivered to:
body.onclick
body.attachEvent
documentElement.onclick
documentElement.attachEvent
document.onclick
document.attachEvent
NOT: window.onclick, if body.onclick is set
NOT: window.attachEvent
setting a single handler:
setAttribute function
expando function
getting a single handler:
n.getAttribute is a function
n.expando is a function
Mozilla:
in head: document.documentElement set, document.body==null
onload is delivered to:
window.onload or inline body.onload (latter winning)
window.addEventListener (in registration order, regardless of useCapture)
NOT delivered to document or documentElement
onclick is delivered to:
documentElement.addEventListener(useCapture=true)
body.onclick
body.addEventListener(false)
documentElement.onclick
documentElement.addEventListener(false)
document.onclick
document.addEventListener(false)
window.onclick [even if body.onclick is set]
window.addEventListener(false)
setting a single handler:
setAttribute string
expando function
getting a single handler:
n.getAttribute is string, if any. (null if set via expando function)
n.expando is function (set via either setAttribute string or expando function)
Opera:
in head: document.documentElement set, document.body==undefined
onload is delivered to:
document.addEventListener(true)
documentElement.addEventListener(true)
inline body.onload
document.onload
window.attachEvent
document.addEventListener(false)
NOT: documentElement.addEventListener(false) [bug?]
NOT: window.onload
onclick is delivered to:
documentElement.addEventListener(useCapture=true)
body.onclick
body.addEventListener(false)
documentElement.onclick
documentElement.addEventListener(false)
document.onclick
window.attachEvent
document.addEventListener(false)
NOT: window.onclick, if body.onclick is set
setting a single handler:
setAttribute string
expando string
expando function
getting a single handler:
n.getAttribute is string, if any. (empty string if set via expando function)
n.expando is function (set via either setAttribute string or expando function)
Safari:
in head: document.documentElement set, document.body==null
onload is delivered to:
document.addEventListener(useCapture=true)
documentElement.addEventListener(true)
window.addEventListener(false)
window.addEventListener(true) [bug?]
inline body onload
onclick is delivered to:
documentElement.addEventListener(useCapture=true)
body.addEventListener(false)
documentElement.addEventListener(false)
document.addEventListener(false)
window.addEventListener(false)
body.onclick
documentElement.onclick
document.onclick
window.onclick [even if body.onclick is set]
setting a single handler:
setAttribute string
expando function
getting a single handler:
n.getAttribute is string, if any. (null if set via expando function)
n.expando is function (set via either setAttribute string or expando function)
Conclusions:
onload:
IE: window.attachEvent [after]
Mozilla: window.addEventListener [useCapture irrelevant; after]
Opera: document.addEventListener(true) [before] or window.attachEvent [middle] or document.addEventListener(false) [after]
Safari: window.addEventListener [useCapture irrelevant; before]
onclick (prefering latest/highest possible):
Mozilla: window.addEventListener(false) [after; document also works]
IE: document.attachEvent [after]
Opera: document.addEventListener(false) [after]
Safari: window.addEventListener(false) [before; document also works]
setting a single handler:
IE: must be a function, whether setAttribute or expando
else: use setAttribute for string, expando for function.
getting a handler:
n.expando always works if you want a function
n.getAttribute returns a string, but it is null or empty string if originally set via expando function