DOM Scripting
Simon P. Chappell writes "This is an unusual book in a good way. It covers a subject normally the preserve of geeks while being targeted at designers. Not a common approach, but one that Jeremy Keith pulls off rather handily. Mr. Keith is an active member of the Web Standards Project's Scripting Task Force; he not only knows how to script web pages, but he knows how to use that scripting to enhance the page's conformance to standards and even increase a site's accessibility. If you are like me, and have put off working with JavaScript because of the standards issues, then this book is our notification that those days are behind us. If you are a web designer who is interested in using dynamic techniques to enhance your site, but had feared the wrath of the standards police, this book is for you." Read the rest of Simon's review.
DOM Scripting
author
Jeremy Keith
pages
341 (12 page index)
publisher
Apress
rating
10/10
reviewer
Simon P. Chappell
ISBN
1590595335
summary
A tour de force that is destined to be called a classic.
I think that it's important to note that this is not a book about Ajax. For those of us feeling overly bombarded with Ajax this and Ajax that, this book is a delightful and refreshing read. Mr. Keith goes beyond the hype and brings us a strong explanation on one of the fundamental pillars of Ajax: working with the Document Object Model (the DOM of the title) using JavaScript. Without DOM Scripting there could be no Ajax, so this is an important addition to the library of any Web Developer who plans to create dynamic Web Applications. Who's it for?
According to the introduction: "This book deals with a programming language, but it isn't intended for programmers. This is a book for web designers. Specifically, this book is intended for standards-aware designers who are comfortable using CSS and XHTML." Mr. Keith is good to his word and his book is wholly targeted at web designers. That being said, I also found that the book was very suitable for programmers, myself included, who have been putting off using JavaScript in any depth. The Structure
The book's structure is fairly standard (no pun intended) and each chapter builds upon the proceeding one. The exceptions to this are the first and last chapters where the history of JavaScript and the future of DOM scripting are discussed, respectively.
Chapter two introduces JavaScript syntax and does a pretty good job considering that it is only 26 pages long. Chapter three then covers the Document Object Model. With the basic concepts of JavaScript and the DOM covered, the rest of the book proceeds to show us how to use them together.
Chapter four works through a basic JavaScript driven image gallery. This gallery is then revisited in chapter six where the JavaScript is upgraded to allow it to degrade gracefully according to the level of JavaScript functionality available in the browser and to ensure that the JavaScript is as unobtrusive as possible. Our final visit to the gallery example is in chapter seven where we learn to create markup on the fly and see how it can be usefully applied to enhance the gallery even further.
Chapter five looks at best practices for web design and how JavaScript and DOM scripting fit into that. Chapter eight takes a break from image galleries and looks at how DOM Scripting can help enhance our existing text content. Enhancement is also the focus of chapter nine, where the intersection and interaction of CSS and the DOM is explored.
Chapter ten is a little bit of fun, taking a look at animation through DOM Scripting. Chapter eleven, called "Putting It All Together" is a case study where a website is created for an imaginary band called "Jay Skript and the Domsters". The name may be corny, but the example is a wonderful display of starting with plain content and enhancing it using only standard compatible techniques. The book wraps up with an appendix of reference information of the JavaScript used in the book. What's to Like?
For a book that is not aimed at programmers, it is a great introduction to programming in JavaScript. Every concept is introduced clearly and the reasoning behind each approach is explained and the justification for it provided.
The book is very comfortable to read. The physical size, the typography, the design and the layout are all excellent. This is not surprising considering the target audience; excellent design is the minimum price of admission to the library of those in the design industry. What's to Consider?
There is very little that I did not like in this book. Although, I think that that it would be useful to point out again, that this isn't specifically written for programmers. If you know JavaScript well, this may not be the book for you. If you have extensive browser scripting experience this may also not be for you. And lastly, if you have no need, desire or interest in standards based scripting, this is absolutely not the book for you.
This is not a reference book. It will teach you a solid core of JavaScript suitable for working with the DOM, but do not think that it will teach you everything that there is to know about JavaScript. While the back of the book does have a small reference section, it is only for the concepts taught in the book. Website
Of course, the book has a website, available at domscripting.com. The site has an active blog and the finished version of the example site for "Jay Skript and the Domsters". Conclusion
This book deserves to be promoted to classic status immediately. It is written clearly, it uses only good principles of programming and adheres strictly to the appropriate standards. What a combination."
You can purchase DOM Scripting from bn.com. Slashdot welcomes readers' book reviews -- to see your own review here, read the book review guidelines, then visit the submission page.
I think that it's important to note that this is not a book about Ajax. For those of us feeling overly bombarded with Ajax this and Ajax that, this book is a delightful and refreshing read. Mr. Keith goes beyond the hype and brings us a strong explanation on one of the fundamental pillars of Ajax: working with the Document Object Model (the DOM of the title) using JavaScript. Without DOM Scripting there could be no Ajax, so this is an important addition to the library of any Web Developer who plans to create dynamic Web Applications. Who's it for?
According to the introduction: "This book deals with a programming language, but it isn't intended for programmers. This is a book for web designers. Specifically, this book is intended for standards-aware designers who are comfortable using CSS and XHTML." Mr. Keith is good to his word and his book is wholly targeted at web designers. That being said, I also found that the book was very suitable for programmers, myself included, who have been putting off using JavaScript in any depth. The Structure
The book's structure is fairly standard (no pun intended) and each chapter builds upon the proceeding one. The exceptions to this are the first and last chapters where the history of JavaScript and the future of DOM scripting are discussed, respectively.
Chapter two introduces JavaScript syntax and does a pretty good job considering that it is only 26 pages long. Chapter three then covers the Document Object Model. With the basic concepts of JavaScript and the DOM covered, the rest of the book proceeds to show us how to use them together.
Chapter four works through a basic JavaScript driven image gallery. This gallery is then revisited in chapter six where the JavaScript is upgraded to allow it to degrade gracefully according to the level of JavaScript functionality available in the browser and to ensure that the JavaScript is as unobtrusive as possible. Our final visit to the gallery example is in chapter seven where we learn to create markup on the fly and see how it can be usefully applied to enhance the gallery even further.
Chapter five looks at best practices for web design and how JavaScript and DOM scripting fit into that. Chapter eight takes a break from image galleries and looks at how DOM Scripting can help enhance our existing text content. Enhancement is also the focus of chapter nine, where the intersection and interaction of CSS and the DOM is explored.
Chapter ten is a little bit of fun, taking a look at animation through DOM Scripting. Chapter eleven, called "Putting It All Together" is a case study where a website is created for an imaginary band called "Jay Skript and the Domsters". The name may be corny, but the example is a wonderful display of starting with plain content and enhancing it using only standard compatible techniques. The book wraps up with an appendix of reference information of the JavaScript used in the book. What's to Like?
For a book that is not aimed at programmers, it is a great introduction to programming in JavaScript. Every concept is introduced clearly and the reasoning behind each approach is explained and the justification for it provided.
The book is very comfortable to read. The physical size, the typography, the design and the layout are all excellent. This is not surprising considering the target audience; excellent design is the minimum price of admission to the library of those in the design industry. What's to Consider?
There is very little that I did not like in this book. Although, I think that that it would be useful to point out again, that this isn't specifically written for programmers. If you know JavaScript well, this may not be the book for you. If you have extensive browser scripting experience this may also not be for you. And lastly, if you have no need, desire or interest in standards based scripting, this is absolutely not the book for you.
This is not a reference book. It will teach you a solid core of JavaScript suitable for working with the DOM, but do not think that it will teach you everything that there is to know about JavaScript. While the back of the book does have a small reference section, it is only for the concepts taught in the book. Website
Of course, the book has a website, available at domscripting.com. The site has an active blog and the finished version of the example site for "Jay Skript and the Domsters". Conclusion
This book deserves to be promoted to classic status immediately. It is written clearly, it uses only good principles of programming and adheres strictly to the appropriate standards. What a combination."
You can purchase DOM Scripting from bn.com. Slashdot welcomes readers' book reviews -- to see your own review here, read the book review guidelines, then visit the submission page.
Finally the designer guys will be able to learn basic standards compliant js and stop using the prefabricated, outdated do-not-touch messy scripts that still deal with things like "if(document.all)".
:)
When I started programming js, I didn't know where to look so i went for the javascript repositories and search for the script I wanted. If I had a book like this one, I would've written it myself.
And I'm sure that if designers want to delve into the source code, they'll prefer clean, well-intended code rather than the automated (eew) javascript generated by Macromedia^H^H^H^H^H^H^H^H^HAdobe applications.
Thumbs up
...have put off working with JavaScript because of the standards issues, then this book is our notification that those days are behind us.
Sorry, but I have to disagree with you immensly on this point.
There were, and still are, drastic differences between browsers in terms of JavaScript and even DOM. A cursory glance at http://www.quirksmode.org/ shows what I'm talking about.
Standardizing javascript now, or in the future, has no bearing on supporting the past and present. Unless you can afford to not support browsers... IE doesn't fully support setAttribute() yet (id, class, for, onClick, etc.). Firefox doesn't support innerText, outerHTML, nor outerText. IE doesn't support cssRules but does rules while Firefox is the exact opposite (opera does neither).
JavaScript has a long ways to go and no book is going to erase these vast differences no matter how well written it is.
It seems the only way we'll get out of the javascript mess is by everyone supporting everything or an entire new language is created with a strict API defined. Then again, HTML & CSS are still up in the air so standards aren't the whole solution.
:wq
"Mr. Keith is an active member of the Web Standards Project's Scripting Task Force; he not only knows how to script web pages, but he knows how to use that scripting to enhance the page's conformance to standards and even increase a site's accessibility."
So Taco and friends have a copy of this book on their bookshelf?
Well, I don't know who was responsible for inventing DOM but I have some experience in writing using it, and today I had a refresher on how ugly it is.
i ld(list);
Consider the following piece of HTML:
<ul type="square">
<li><a href="#link1">Page 1</a></li>
<li><a href="#link2">Page 2</a>(new!)</li>
</ul>
Let's rewrite it as DOM:
var list=document.createElement('ul');
list.createAttribute('type','square');
var el1=document.createElement('li');
var el2=document.createElement('li');
var link1=document.createElement('a');
var link2=document.createElement('a');
link1.createAttribute('href','#link1');
link2.createAttribute('href','#link2');
var content1=document.createTextNode('Page 1');
var content2=document.createTextNode('Page 2');
var content3=document.createTextNode('(new!)');
link1.appendChild(content1);
link2.appendChild(content1);
el1.appendChild(link1);
el2.appendChild(link2);
el2.appendChild(content3);
list.appendChild(el1);
list.appendChild(el2);
document.getElementsByTagName('body')[0].appendCh
Of course you will likely pull link URLs from arrays, texts from some resource file, you won't be creating multiple variables to hold similar elements etc, but to create equivalent piece of document you will likely need to use something very similar to the above. (and it's still not the best. link1.remove(); ? No. link1.parentNode.removeChild(link1); link1.replaceWith(link2)? No. link1.parentNode.replaceChild(link1,link2);
Do you already feel about the author of DOM specs the way I feel?
45 5F E1 04 22 CA 29 C4 93 3F 95 05 2B 79 2A B2
I got given this book for Christmas, and find it is really good at teaching you what to do, and why you should do it. Starting as a "newb" I am now able to integrate AJAX through DOM Scripting - something I would never have dreamed of before.
:p
Whether you review the book or the "language" is a different matter. I find both excellent, but some may find that while the book is informative and pretty flawless, the language is not all it's cracked up to be. That's another argument, which I'm sure will be brought up soon
The browser is a *TERRIBLE* platform on which to deliver applications. Sure it's convenient to deliver applications on a thin client platform that already has universal install-base, but today's browser still makes this task very clumsy. DHTML is difficult to debug, you must abstract everything into libraries because of browser differences to get any productivity, scripted client-side code runs terribly slow and unless you are willing to bolt other technologies into the mix you must suffer pathetic 1990's-era least-common-denominator UI constructs like radio buttons and check boxes.
When tools like XUL or XAML truly come online and there are development tools (and debuggers) to support them, thin-client development will get a huge new boost. Until then we will continue to have to "fake it" with clumsy JS and bolt-ons like Applets / ActiveX / Flash / etc.
No sig for you!
http://domscripting.com/book/sample/
They talk about graceful degradation, using code like this:
<a href="http://www.example.com/"
onclick="popUp(this.href); return false;">Example</a>
And about progressive enhancement, with code like:
<p class="warning">
Be careful!
</p>
instead of using font tags.
Finally, a book which tells you how to do it right from the beginning.
This is why I have a stack helper class. For me it looks like:
ds = new DOMStack( "containerdivname" );
ds.push( "ul" );
ds.setAtt( "type" , "square" );
ds.push( "ul" );
ds.pushA( "#link1" , "Page 1" );
ds.popInto( ); ds.popInto( );
ds.push( "ul" );
ds.pushA( "#link2" , "Page 2" );
ds.popInto( );
ds.pushText( "(new!)" );
ds.popInto( );
ds.popInto( );
Except that it's almost never hardcoded, or I'd just write it in HTML in the first place.
(and I've chucked in a bunch of semantics-neutral whitespace to keep slashdot from inserting sematics-changing whitespace)
oops
When a browser/OS combination determines how something renders, like an input type="file" element. Want to stylize it? The page at http://www.quirksmode.org/dom/inputfile.html provides some guidance, but holy crap, what a friggin pita!
[this I know, spending a few hours trying to maybe write my own version with no better luck]
I only post comments when someone on the internet is wrong.
Thanks.
If anyone has a good idea on how to automatically (or mostly automatically) generate a script to login and download data from a website, please let me know. Thanks.
EvilCON - Made Famous by
Take a look at this AJAX DOM Scripting web site http://www.gendivide.com/ . It appears to offer alot of dynamic functionality. Very fast. Doesn't like old people though.
Its my experience that good web designers have learned to use the DOM quite well. Granted they started by patching together examples from http://alistapart.com/ to make their CSS more flexible and cross browser, but as it stands today, at least at my company, we differ to the designers for most DOM scripting. We only hire CSS/Standards based designers so that likely contributes to our technicaly savvy design team, but when the C# guys admit that the design kids are better suited to front-end scripting tasks that speaks volumes. So next time you cop out and limit your app for fear of unsolvable x-browser issues remember that 19 year old kids fresh out of design school are pulling it off everyday. On a side note... don't say DHTML... we're in the age of CSS, AJAX and unobtrusive JS... DHTML was the age of .
But what if I've put off working with Javascript because of the suckage issue?