I read that attach.event is only used in early versions of IE. I was wondering why it is used here, it seems to correspond to executing the populateFigures() part of the setUpPage() function, is this correct? I really appreciate any help!
function setUpPage() {
createEventListeners();
populateFigures();
}//end of setUpPage Function
/* run setUpPage() function when page finishes loading */
if (window.addEventListener) {
window.addEventListener("load", setUpPage, false);
} else if (window.attachEvent) {
window.attachEvent("onload", setUpPage);
}//end of else if
Yes this is correct.
It is just to make sure that
onloadshould work in IE (6 to 10) becuase of limited support ofaddEventListenerin these versions of IE.So your code is checking if property
addEventListeneris present in thewindowobject then add an event usingaddEventListenerotherwise if the propertyattachEventexists (primarily on IEs) on window object then add event usingaddEventListener.Read more about attachEvent here.