🔰event handler
event (function) handler
argument:an Event object.
this
refers to the object on which the handler was registered.
return value: In modern JavaScript, event handlers should not return anything.
event handler can also be an object - 👉 see: object handler
Window-reflecting body element event handlers:
if you assign one of the following event handlers on document.body, it will be reflected on window too, and vice versa.
onblur, onerror, onfocus, onload, onresize, onscroll
const body = document.body;
body.onblur = function f(){}; // assigned on body
window.onblur // f: reflected on window
window.onresize = function g(){}; // assigned on window
body.onresize // g: reflected on body
📗 Medium
Last updated
Was this helpful?