DOM Scripting

9 comments | Posted: 29 November 05 in Books, by Nathan Smith

DOM Scripting Over Thanksgiving break, I was able to set aside some time to get reading done that I have been putting off for awhile. I have just finished reading the tome of knowledge entitled DOM Scripting, and have to say that I was very pleased with this book. It is written by Jeremy Keith, who is one of, if not the leading expert in JavaScript and the Document Object Model. The forward to the book is done by Dave Shea, curator of the popular site CSS Zen Garden.

In the case of highly technical subjects, documentation is usually quite widespread. Most programming textbooks will tell you what you need to know, in some way or another. The thing I like about this one is the way in which Jeremy presents the information. He uses everyday, practical examples of JavaScript, such as making an interactive photo gallery.

I also like how he does not tout JavaScript as the end-all solution for web design. In several cases, he will show how to do something with JavaScript, and then gives a more simple example of how it would work with CSS. He makes mention of how simple image roll-overs need not be handled by JS anymore, because of the CSS a:hover handles it better and with less code.

This book relates to the reader in a manner that assumes a shared basic knowledge of XHTML and CSS. It is full of examples of selecting nodes via the getElementByTagName() method, not unlike the way CSS interacts with the DOM. By using CSS, every H1 in a document can be given a certain style.

By using JavaScript, you can affect these by changing color, margin or padding directly. Jeremy gives examples of how instead of re-defining these types of things with JS, you can simple assign a different class name to them, and control the styles via CSS, the way you normally would.

He also shows how to impliment current-page indicators in a navigation system, but conceeds that things like this are better handled with server-side scripting. It is refereshing to see an author who is humble about his area of expertise, presenting it as a piece of a larger system, and showing areas in which it might not be the best fit for the task at hand.

I could go on and on, but I think that if I give away too much, that might be giving you the book for free. So, take my advice: If you are wondering what all this DOM / Ajax buzz is, then go get this book. It will give you a solid handle on the underlying principles of the DOM, and show you how to use a combination of JavaScript and CSS to best manipulate behavior within your web pages.

Discuss This Topic

  1. 1 Yannick

    Awesome, thanks for the review Nathan. Christmas is coming up and I’m definitely thinking of putting this on my list. :)

     
  2. 2 Rob

    Sweet writeup Nathan, thanks. I’m thinking, like Yannick, that i’m gonna have to put that one on my Christmas list too!

    Also here’s a cool example of real life DOM stuff that i used for a work project. Don’t enter any values and then submit the form. The JavaScript dynamically changes the style of the input fields and then adds a JavaScript listener so when you then enter a value it changes the class back. Check it out!

     
  3. 3 Ryan Heneise

    Thanks for the recommendation. I’ve been using all kinds of DOM scripts (like the Prototype library) and getElementById and getElementByClass gizmos without really understanding how they work, and it’s really starting to get to me. This sounds like just what I need to begin to get a better understanding of the DOM.

     
  4. 4 Nathan Smith

    Rob: I tried out that form, that is pretty sweet. This was a contract job for IBM? Kudos man, working for the Big Blue! Audits though, shudders.

     
  5. 5 Robert

    I will have to check out this book, thanks for the article.

     
  6. 6 Jeremy Keith

    Thanks for the very kind words, Nathan. I’m glad you liked the book and that it proved useful to you.

     
  7. 7 Nathan Smith

    Jeremy: You’re welcome, and I’m flattered you took the time to stop by and thank me. It reinforces my opinion that this book was a labor of love, so to speak. It’s evident in your approach to the material that it is something you are not only proficient at, but also care a great deal about. That is refeshing to see.

     
  8. 8 Vesa Virlander

    I’ll have to buy this one for sure, thanks from the review!

     
  9. 9 Nathan Smith

    Vesa: You’re very welcome. I’ve found it to be a great resource to keep close by, when all those JS terms start getting muddled in my mind.

     

Comments closed after 2 weeks.