14.08.2016 Views

Beginning JavaScript with DOM Scripting and Ajax, 2nd Edition

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

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

Chapter 6 ■ Common Uses of <strong>JavaScript</strong>: Images <strong>and</strong> Windows<br />

accidentally closing the window your web site needs. Years of unsolicited advertising <strong>and</strong><br />

pop-ups have conditioned web surfers to immediately close new windows <strong>with</strong>out even<br />

glancing at them.<br />

• Employing timed execution of code via the window methods setTimeout() <strong>and</strong><br />

setInterval() is a bit like using makeup: as a girl you learn how to put it on; as a woman<br />

you learn when to take it off. You can use both of these methods—<strong>and</strong> they are tempting to<br />

create all kinds of snazzy effects—but you should think of your users, <strong>and</strong> ask yourself,<br />

“Is there really a need for animation when a static interface might lead much more quickly<br />

to the same result?”<br />

Summary<br />

Well done! You have reached the end of this chapter <strong>and</strong> should be well equipped now to create your own <strong>JavaScript</strong><br />

solutions <strong>with</strong> images <strong>and</strong> windows, or—even better—window replacement techniques.<br />

If some of the examples were a bit tough to wrap your head around, don’t get frustrated, because this is a feeling<br />

you’ll experience often as a <strong>JavaScript</strong> developer. And it does not mean that you don’t get it. Dozens of ways exist to<br />

solve any given problem in <strong>JavaScript</strong>. Although there are much easier ways than those explained here, getting used to<br />

this kind of scripting should make you well equipped for more advanced scripting tasks like using third-party APIs or<br />

web application development.<br />

In the next chapter, you have the chance to become better acquainted <strong>with</strong> event <strong>and</strong> property h<strong>and</strong>ling, as we<br />

discuss navigation <strong>and</strong> forms.<br />

www.it-ebooks.info<br />

197

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

Saved successfully!

Ooh no, something went wrong!