Assuming the function doSomething()
is defined in the same place, does the function's scope when it is executed differ between these three methods of listening for events?
<body onload="doSomething();">
document.body.onload = doSomething;
document.body.addEventListener('load', doSomething);
Aside from attributes only being able to contain one "listener" compared to addEventListener()
, are there any other differences between listening for events in these three ways? (such as passed in parameters, or the value of this
?)