Sunday, 25 August 2013

Event Handling with Function Literals

Event Handling with Function Literals

So I've been going through Head First JavaScript and I came to a section
on Event Handling with Function Literals. The book explains that you can
wire all your event handling in your 'script' tags. But I am confused on
how I get multiple functions to fire off on one event. Here's my code:
//Event Handling with Function Literals
window.onload = function(evt) {
//THIS IS BROKEN
document.body.onresize = resizeImg();reportImgHeight();
//Onload: Functions to Execute -- THESE WORK
resizeImg();
reportImgHeight();
}
So specifically for this example, how do I get an "onresize" event to
execute BOTH resizeImg and reportImgHeight (functions which I have defined
elsewhere in my code). Thank you!

No comments:

Post a Comment