Book reviewUSENIX

 

Nick Heinle
Designing with JavaScript: Creating Dynamic Web Pages
O'Reilly & Associates, 1997. ISBN 1-56592-300-6. Pp. 241. $29.95. CD included.

Reviewed by Bruce O'Neel
<beoneel@acm.org>

One sign that you are getting older is that the book authors start to seem quite young. The other sign is that you can't imagine that someone that young could write a book, yet alone a reasonable one. Well, Nick Heinle at 17 is less than half my age, but the second prejudice isn't true. This book is good for its target group.

Rather than at programmers, Designing with JavaScript is aimed at Web designers. What is included is a lot of code examples to help you add JavaScript to your Web pages. What is not there is an overview or detailed description of JavaScript. If you are a language person, say, one who reads the C++ Annotated Reference Manual for fun, this is not a good book for you. If you'd like to add JavaScript to Web pages without having to understand more than is necessary, then this is a good book. Given that this is a fluid field, it's tough for a book such as this to remain current, so you'll also find yourself referencing the author's Web site at <http://www.webcoder.com>.

Overall, the explanations are clear, and Mr. Heinle understands that although he's talking to a group of people who possibly don't know about programming, they are not idiots. This is a book that teaches by example, and there are many examples, all of them highlighted in what in the X world I believe would be sea foam green. The book is much more understandable if you already have a good grasp of HTML because, without a good knowledge of HTML, most of the examples will not make a lot of sense. Additionally, you would have a hard time understanding the motivation for the different examples.

Although the examples are clear they suffer from what could be called FORTRAN 66 formatting. A little indentation wouldn't have hurt things for those of us who are used to it. Plus it wouldn't have hurt to show a good formatting style to a group of people whose first experience with programming will be this book. Designing with Java Script also has many highlighted regions that explain more about JavaScript; and, unlike many books, the highlighted sections are quite important to understand JavaScript, and therefore the book itself.

Chapter 1, "Diving into JavaScript," starts right off with some neat JavaScript additions to your Web pages. Each chapter includes a little "In this Chapter" list that lets you quickly decide if this chapter is going to be useful to you. Chapter 1 covers some very basic JavaScript commands such as writing to the currently displayed page, writing to the message window at the bottom of the browser, and some overviews of how the JavaScript object model works. It also includes how to hide JavaScript from older browsers. This is probably the toughest chapter to get through if you aren't a programmer already because lots of programming concepts are introduced in short order. If you can get through this chapter, then the rest of the book shouldn't be too bad.

Chapter 2 covers how to control browser windows, write functions, and create remote controls. A remote control in this case is a detached browser window with buttons that help you navigate around the Web site. Chapter 2 is the first place where the book talks about the differences between various Netscape Navigator (NN) versions, just one of the problems that adds complexity to one's life as a JavaScript programmer.

Chapter 3 tells you how to make JavaScript and frames work together. Yes, those dreaded frames can be made to work better if you are willing to do some programming. Here you also learn how to make expanding and collapsing titles and subtitles in your navigation box.

Chapter 4 shows you how to make JavaScript and forms work together. This is one place where JavaScript can really help because you can have JavaScript do the validations on the client, rather than connecting back to the host for the validations. There also is a long discussion of functions in JavaScript, with a number of good examples to show you practical uses of functions.

Chapter 5 covers arrays and the interesting things you can do with them in JavaScript.

Chapter 6 talks about all the hoops you'll have to go through to make sure you do the right thing, given different browsers. One of the things that makes JavaScript a bit difficult to program in is that each version of NN and Microsoft Internet Explorer (MSIE) implement a slightly different version of JavaScript with different bugs. In fact, in my tests with NN 4.04 on Solaris, I found that a number of the examples didn't quite work as expected. I hope this will settle itself out now that the European Computer Manufacturers Association has started standardizing ECMAscript.

Chapter 7 covers dynamic images. Dynamic images are images that change as different things happen on your Web page. An example of this is when you move your cursor over some part of your Web page, an image changes from a static image, say, of a dog, to a dog wagging its tail. This chapter also talks about preloading images so that when you do move your cursor over some bit of your Web page, something happens beyond trying to connect to a Web site.

Chapter 8 will be a favorite with the privacy folks. Here's where you find out more than you ever wanted to know about cookies from the JavaScript side of things. You'll get to see how to make a welcome mat for a Web site that is displayed the first time a user arrives, as well as forms that remember where you were the last time you visited. Although cookies are controversial, using JavaScript and cookies together at least keeps all the information on the client computer, rather than keeping it on the host computer, which might help with privacy concerns.

Chapter 9 discusses Dynamic HTML (DHTML) and Style Sheets (SS), two new features added in version 4 of NN and MSIE. Here NN and MSIE diverge quite a bit, so this chapter is in two parts, one for MSIE and one for NN. This is a long and involved chapter because there is a lot to learn about DHTML and SS.

Chapter 10 talks about a concept that NN introduced in the first beta of NN called layers. This was superceded by Dynamic HTML and Style Sheets, but this chapter is included for the sake of completeness. It's probably best not to use layers because there are now better ways to accomplish the same task.

Chapter 11 is devoted to a Dynamic HTML application called The Show. The Show is a multiple-choice game, and this is a good example for Dynamic HTML. The downside is that I was not able to get this to work on NN 4.04 on Solaris.

Chapter 12 is a wrap-up chapter called "Advanced Applications." It first talks about user-defined objects. Next it shows three examples of a quiz application, a Web tour, and relational menus. Relational menus are menus where one menu changes in relation to what one choose from the other menu.

The book includes a CD-ROM with all the examples from the book plus a demo version of Acadia's Infuse, a JavaScript programming tool. This being an Internet tool, it's been sold, in this case to NetObjects, and is now called NetObjects ScriptBuilder 2.0. Because there is no Solaris version, I did not get a chance to test it.

This book will work best if you work through it while sitting at a system with an editor and a Web browser up so that you can try the examples as you read. Most of the examples aren't very long, so they aren't going to take too long to enter even though they are on the CD-ROM. If you are new to a language, actually typing the examples in can be a big help in learning that language. It's amazing what the eye misses that the constant banging of finger on key will reinforce.

So, that all important question, is it worth the $30 of your hard earned money? If you're not a programmer and want a fairly easy introduction to JavaScript programming, then yes. If you are an accomplished programmer already, you probably will be happier with a more in-depth book. If you do decide to purchase it, you should work through it as quickly as possible. Time flies in the Internet world, and if you wait too long, the book will become outdated.

 

?Need help? Use our Contacts page.
First posted: 14th July 1998 efc
Last changed: 14th July 1998 efc
Issue index
;login: index
USENIX home