3. The modern event model

Created Saturday 14 June 2014

<script>
window.onload = init();
</script>
OR
<body onLoad="init()">
...
</body>
window.addEventListener("load", onWindowLoad, false);
OR
window.attachEvent("onload", onWindowLoad); // IE 8
DOM: element.addEventListener(evt, fn, capture)
DOM: element.removeEventListener(evt, fn, capture)
IE8: element.attachEvent(evt, fn)
IE8: element.detachEvent(evt, fn)
function addEventHandler(oNode, sEvt, fnHandler) {
if (typeof(window.event) != "undefined")
oNode.attachEvent("on" + sEvt, fnHandler);
else
oNode.addEventListener(sEvt, fnHandler, true);
}
function eventHandler(e) {
var evt = e || window.event;
.....
}



Backlinks: