DOM Scripting

Author: Jeremy Keith & Jeffrey Sambells
Publisher: Friends of Ed, 2011
Pages: 336
ISBN: 978-1430233893
Aimed at: Casual programmers
Rating: 3
Pros: Practical hand-on approach
Cons: Not object-oriented
Reviewed by: Ian Elliot  


The DOM is mostly what JavaScripting is all about so a book on it is a good idea. Is this the one you need?


Author: Jeremy Keith & Jeffrey Sambells
Publisher: Friends of Ed, 2011
Pages: 336
ISBN: 978-1430233893
Aimed at: Casual programmers
Rating: 3
Pros: Practical hand-on approach
Cons: Not object-oriented
Reviewed by: Ian Elliot

 

The DOM is mostly what JavaScripting is all about so a book on it is a good idea. This particular book is a good introduction but there are aspects of it that seem a bit old fashioned - but you might not agree.

The DOM - Document Object Model is how you can get at and modify the structure of an HTML pages. Put simply if you have an object on the page - a button say - then there will be a corresponding object, i.e. a button object in the DOM.  JavaScript is an object oriented language and so you can access and work with the properties of the objects in the DOM and so explore and modify the web page.


Banner

This is more or less what the first two chapters tell you. Chapter 1 is a history of JavaScript and DHTML among other things. Next we have a quick introduction to JavaScript - not deep and not extensive but sufficient. Chapter 3 introduces the DOM via the idea that objects on the page correspond to objects in the DOM. As the object oriented aspects of JavaScript haven't been explained this doesn't integrate well with the the language - it looks as if it has been invented specially to deal with the problem of working with pages. Most of the chapter is about accessing and navigating the DOM, getting and setting attributes. The book once again reveals its non-object oriented approach when the setAttribute and the getAttribute methods are preferred over direct access to a DOM object's property. The rational for this preference is that it always works and the attribute name is the same in HTML and the DOM. A valid point but one that de-emphasises the nature of an object.

Chapter 4 provides the introduction to the example which runs thought the book - an image gallery. Here the ideas of testing for the existence of objects and facilities and gradual enhancement are introduced. The book stresses the idea that you should build a web page so that it delivers as much as possible if the browser or the user decides not to support JavaScript or feature. It is difficult to argue with this point of view but it is clear that if we continue in this way the result will be that we will stay in the stone age of the web until the last old browser is put to death. A more modern and brutal approach might be to state clearly that the page wont work and provide a link to a download of a modern browser that will make it work - but each to there own and knowing how to deal with the lack of a facility isn't bad. Chapter 5 hammers home the idea of graceful degradation and explains a lot of other connected ideas before moving on to extend the image gallery in the next chapter.

Chapter 7 deals with creating markup on the fly i.e. adding nodes to the DOM. This starts off dealing with old fashioned methods such as write but quickly gets to the createElement method and similar methods that add objects to the DOM. It is at this point that the lack of an object oriented approach a missed opportunity. It is so much easier to wrap up new DOM objects as JavaScript objects but... just working with the DOM in this way is a valid approach. The chapter also introduces Ajax and the XMLHttRequest object which in most cases is where the real advantage of using scripting and the DOM starts.

The next chapter is about enhancing content and again it repeats the progressive enhancement/ graceful degradation approach and these ideas are used in the next chapter to create an animated slideshow.

This is more or less where the core of the book ends. We next have a grafted on chapter about HTML5 - canvas and the audio/video tags. Then a rounding out chapter called putting it all together which introduces the form at quite a late stage.

Finally we have some appendices - the first on DOM Scripting libraries which of course is the correct way to go if you want to write DOM scripts. So after 12 chapters of finding out how to do it the hard way you are introduced to the easy way - if that is you do read the appendix.

This book provides a very old school approach to programming the DOM using a non-objected oriented approach. As such it will suit a reader who really doesn't want to learn to program but just create a few improvements to a web page.

If you want to do the job properly, and this of course is what I would recommend, then learn JavaScript well, understand objects and the DOM is then obvious. In any case using DOM raw isn't a good a and modern way to go about things - it's much better to use a DOM library such as jQuery.

If you want to cut corners and prefer the traditional approach this book isn't a bad choice. However, despite it introducing JavaScript and HTML, it isn't really suited for the complete beginner.

Banner


Web Design, 7e (In Easy Steps)

Author: Sean McManus
Publisher: Easy Steps, 7th Ed, 2023
Pages: 228
ISBN: 978-1840789850
Print: 1840789859
Kindle: B0C24YV788
Audience:
Rating: 4
Reviewed by: Sue Gee
Web design without a designer - is it possible?



Seriously Good Software

Author: Marco Faella
Publisher: Manning
Date: March 2020
Pages: 328
ISBN: 978-1617296291
Print: 1617296295
Kindle: B09782DKN8
Audience: Relatively experienced Java programmers
Rating: 4.5
Reviewer: Mike James
Don't we all want to write seriously good software?


More Reviews

Last Updated ( Tuesday, 19 July 2011 )