Chapter 14. 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, and modifying the content on your web page. On the other hand, it can’t help you build a hot ecommerce storefront; for that, you need the PayPal tools described in Chapter 13 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 free JavaScript code online, understand it well enough to make basic changes, and then paste it into your pages to get the results you want.


In fact, you’ve already used JavaScript (perhaps unwittingly) in some of the examples in this book. You used it to track visitors to your site with Google Analytics (Understanding Google Analytics), to fetch a suitable block of ads for your AdSense-enabled web page (Placing Ads in Your Web Pages), and to grab a list of your recent tweets to show on your site (Sharing Your Tweets on Your Site). In all these cases, you used a block of ready-made JavaScript code (or a reference to a ready-made JavaScript file). You got the benefits of JavaScript interactivity without needing to write ...

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

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