Chapter 15. JavaScript: Adding Interactivity

JavaScript is a simplified programming language designed to beef up web pages with interactive features. It gives you just enough programming muscle to add some fancy effects, but not enough to cause serious damage to your site if your code goes wonky. JavaScript is perfect for creating pop-up windows, embedding animated effects, or modifying the content that appears on your web page. On the other hand, it can’t help you build a hot e-commerce storefront; for that, you need the PayPal tools described in Chapter 14 or a server-side programming platform (see Server-Side and Client-Side Programming).

The goal of this chapter isn’t to teach you the details of JavaScript programming—it’s to give you enough background so you can find great JavaScript code online, understand it well enough to make basic changes, and then paste it into your pages to get the results you want. Since you can find free JavaScript code on hundreds of websites, these basic skills can come in very handy.

Understanding JavaScript

The JavaScript language has a long history; it first hit the scene with the Netscape Navigator 2 browser in 1995. Internet Explorer jumped on the bandwagon with version 3. Today, all modern browsers run JavaScript, and it’s become wildly popular as a result.


JavaScript is thoroughly different from the Java language (although the code sometimes looks similar, because they share some code-writing rules). Java is a full-fledged programming language, ...

Get Creating a Website: The Missing Manual, 3rd Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.