DOM Scripting

DOM Scripting

  • Web Design with JavaScript and the Document Object Model
  • Jeremy Keith
  • Web Design
  • Amazon.co.uk

Over the last couple of years I’ve read many great books about web design and standards generally. How to keep the presentation layer separate from the mark-up etc. But I had never bought, or read for that matter, any books about JavaScript, until now.

I had used JavaScript at work a few years ago. I liked the immediacy of it, being a scripting language and not a compiled one, but I didn’t like how fussy it was and what a pain it was to debug. Alert boxes seem fine at first until you have to put them in a loop. Then there was all that browser sniffing, that I had seen when I’d viewed the source of web sites, that all seemed tortuous.

The cover of the book mentions “unobtrusive JavaScript” which I thought meant that you would have your JavaScript in a separate file, that’s pretty much a no-brainer, then you would just have ‘onClick’ event calls to your functions. Jeremy describes techniques that are much neater and cleaner than that. What he basically suggests is that you can have your JavaScript search down the DOM, finding a node with a specific class, then add dynamic effects to any of the child nodes underneath. One of the initial examples is a Gallery. Just a list if links pointing to images using ‘a’ tags. What the JavaScript does is find these tags and display the image underneath the list of links on the page. Even the position of the photo is generated by JavaScript.

One thing that he does keep mentioning is the fact that some browsers may not have support for JavaScript or that JavaScript has been disabled. In this case he says that, whatever the page does dynamically using JavaScript, it must also still do without JavaScript. Even if it doesn’t look as swish or if it takes a page load to achieve.

The book covers pretty much everything you need to know to add some sparkle to your web sites. From basic JavaScript programming to AJAX and HIJAX. I managed to read it all away from the keyboard, but to get the most out of it you would have to work through the examples. A good book for someone who wants to know how to use JavaScript correctly and with the least fuss and excessive coding. Not a book for someone who just wants to add flying pink elephants to their homepage.

  • Reviewed on Sunday, 22 January 2006
  • Tagged with book review