11.12.2012 Views

JavaScript 2.0-The Complete Reference, Second ... - freecodingtutorial

JavaScript 2.0-The Complete Reference, Second ... - freecodingtutorial

JavaScript 2.0-The Complete Reference, Second ... - freecodingtutorial

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

this is to assign handlers after the document‘s onload handler fires. Another way to ensure this<br />

condition is to place the script that assigns the handler after the element in question.<br />

Event Handler Scope<br />

As we discussed in Chapter 9, a script‘s execution context is normally the Window in which the<br />

script‘s text is found. However, script included in the text of an event handler has the context of<br />

the object to which it is bound. Instead of this pointing to the Window, this points to the object<br />

representing the element. Given the following script,<br />

<br />

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!