15.02.2013 Views

JavaScript Examples Bible - UserWorks Technologies

JavaScript Examples Bible - UserWorks Technologies

JavaScript Examples Bible - UserWorks Technologies

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Chapter 2 ✦ Window and Frame Objects (Chapter 16)<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

When you try this page, also turn off window event capture. Now only the buttons’<br />

onClick event handlers execute, and the page does not flash red.<br />

clearInterval(intervalIDnumber)<br />

NN2 NN3 NN4 NN6 IE3/J1 IE3/J2 IE4 IE5 IE5.5<br />

Compatibility ✓ ✓ ✓ ✓ ✓<br />

Example<br />

See Listings 16-36 and 16-37 for an example of how setInterval() and<br />

clearInterval() are used together on a page.<br />

clearTimeout(timeoutIDnumber)<br />

NN2 NN3 NN4 NN6 IE3/J1 IE3/J2 IE4 IE5 IE5.5<br />

Compatibility ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓<br />

Example<br />

The page in Listing 16-22 features one text field and two buttons (Figure 2-6). One<br />

button starts a countdown timer coded to last one minute (easily modifiable for<br />

other durations); the other button interrupts the timer at any time while it is running.<br />

When the minute is up, an alert dialog box lets you know.<br />

Listing 16-22: A Countdown Timer<br />

<br />

<br />

Count Down Timer<br />

<br />

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

Saved successfully!

Ooh no, something went wrong!