O'Reilly logo

JavaScript: Visual QuickStart Guide, Eighth Edition by Dori Smith, Tom Negrino

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

2. Start Me Up!

In This Chapter

Where to Put Your Scripts 23

About Functions 25

Using External Scripts 26

Putting Comments in Scripts 29

Alerting the User 31

Confirming a User’s Choice 33

Prompting the User 35

Redirecting the User with a Link 37

Using JavaScript to Enhance Links 39

Using Multi-Level Conditionals 43

Handling Errors 46

Enough of the warm up; it’s time to get scripting. In this chapter, you’ll learn where to put your scripts in your HTML; how you can leave comments in your scripts so that you can more easily understand them at a later time; and how you can use scripts to communicate with the user. You’ll also see how to make the page automatically change to another page (called redirection). Let’s get to it!

Table 2.1. Just Enough ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required