O'Reilly logo

Beginning Web Programming with HTML, XHTML, and CSS, Second Edition by Jon Duckett

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

Chapter 12. Working with JavaScript

You learned the key concepts behind the JavaScript language in Chapter 11; in this chapter, you see how these concepts come together in working scripts. By examining many examples, you learn different ways in which JavaScript can interact with your web pages. You also learn some new coding practices for writing your own JavaScripts, and some very helpful shortcuts to creating interactive pages.

The chapter covers the following major topics, each relating to different JavaScript techniques or parts of documents:

  • Validation of forms: Checking that a user has filled in the appropriate form elements and has put a value that matches what you expect

  • Other forms techniques: Giving focus to elements when the page loads, auto tabbing between fields, disabling controls, and converting text case

  • Navigation: Image rollovers and highlighting navigation items

  • Windows: Creating pop-ups

  • Using existing libraries: Taking a look at three existing JavaScript libraries that can give you complex functionality with just a few lines of code

By the end of the chapter, not only will you have learned a lot about using JavaScript in your pages, but you will also have a library of helpful functions you can use in your own pages.

Practical Tips for Writing Scripts

Before you start looking at the examples, there are a few practical hints on developing JavaScripts that should save you time.

Has Someone Already Written This Script?

Thousands of free JavaScripts are already out there on ...

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