JavaScript and DHTML Cookbook 153
JavaScript and DHTML Cookbook | |
author | Danny Goodman |
pages | 576 |
publisher | O'Reilly & Associates |
rating | 8.5 |
reviewer | Ada Shimar |
ISBN | 0596004672 |
summary | A surprisingly useful JavaScript book, even for people skilled with the language already. |
I'll begin my review by making a bold statement -- if you've read and like O'Reilly's Definitive Guides on JavaScript and DHTML, you'll adore this book. I use the word adore very deliberately here, because in my opinion JavaScript & DHTML Cookbook is much easier to love than the gigantic and sometimes monotonous Definitive Guide series. Why, you ask? Let's see -- the book is compact (some 500 pages), concise, and filled with the essence of JavaScript and DHTML as far as what you can create using the language/ technology.
JavaScript & DHTML Cookbook is broken up into 15 chapters, each containing a series of recipes. The chapters are:
- Strings
- Numbers and Dates
- Arrays and Objects
- Variables, Functions, and Flow Control
- Browser Feature Detection
- Managing Browser Windows
- Managing Multiple Frames
- Dynamic Forms
- Managing Events
- Page Navigation Techniques
- Managing Style Sheets
- Visual Effects for Stationary Content
- Positioning HTML Elements
- Creating Dynamic Content
- Dynamic Content Applications
These chapters are used mainly to facilitate the look up of a particular recipe, as each recipe exists and is explained independent of one another. This is consistent with the style of most Cookbooks, and it seems to work well here as well.
If you're a complete novice, you may be wondering at this point the distinction between JavaScript and DHTML. The book doesn't make a conscious effort to differentiate between the two when discussing recipes, and for a good reason. DHTML is basically JavaScript, though the latter draws in your page's HTML and often CSS as well to create something more encompassing.
Ok, on to what's important now -- the recipes themselves. I was expecting a series of flashy, long and tacky JavaScripts you can find in the source of every other site on the web these days, padded with some nonsense accolade like "the web cannot survive without them." Such scripts are mostly counterproductive, and do little to educate a JavaScript learner, let alone a master like myself (hur hur). To my delight, things were the complete opposite. The recipes in JavaScript & DHTML Cookbook are extremely practical, well thought out, and even educational. Discussions like Calculating the Number of Days Between Two Dates, Simulating a Hash Table for Fast Array Lookup, and Transforming XML Data into HTML Tables not only are very useful to the cut-and-paster, they teach even seasoned JavaScripters a thing or two about the language.
The only minor compliant I have with this book is the length of some of the script examples -- they span a little too long to follow effortlessly. The longest script I can recall in the book runs about 5 pages in length. Fortunately, such recipes are few and far in between, and 95 percent of the recipes are extremely short in length and packed with useful information and techniques. For the long scripts, it's easy to see that they exist out of necessity to create and show a fully functional script rather than just to pad pages.
In summary, I walk away from reading JavaScript & DHTML Cookbook with many new tricks up my sleeve, something I had not expected at all. Some good resources online that compliment the reading would be DevEdge's JavaScript Reference and JavaScriptKit's JavaScript tutorials."
You can purchase JavaScript and DHTML Cookbook from bn.com. Slashdot welcomes readers' book reviews -- to see your own review here, read the book review guidelines, then visit the submission page.
You know the world has changed... (Score:5, Funny)
Re:You know the world has changed... (Score:2)
Re:You know the world has changed... (Score:4, Insightful)
Most O'Reilly books are actually less voluminous than comparable computer books from other publishers.
JP
for those too cheap to buy a book (Score:5, Informative)
http://www.irt.org/index.htm
if you need more help, you should try marketing instead.
Re:for those too cheap to buy a book (Score:5, Funny)
Re:for those too cheap to buy a book (Score:4, Insightful)
And it is my site too!
Re:for those too cheap to buy a book (Score:2, Informative)
irt.org is a very nice site. Your javascript FAQ has saved my ass more times than I can count. It's certainly the first place I go when I have a javascript problem or just need a quick solution. Mega-kudos to you my friend.
Re:for those too cheap to buy a book (Score:3, Informative)
irt.org is pretty much my *only* reference for javascript stuff other than my JavaScript Bible...
Thanks again.
Re:for those too cheap to buy a book (Score:5, Informative)
Re:for those too cheap to buy a book (Score:2)
Uh oh... considering the response of your site at this point, it looks as though your anti-/. request was in vain...
Re:for those too cheap to buy a book (Score:2)
Re:for those too cheap to buy a book (Score:2)
He has mastered hyperlinking.
As much lookee lookee clikee clikee as has been going on,
Anybody interested can surely copy/type the link into a browser.
Like your sig? (-1, flamebait) (Score:1)
Re:Like your sig? (-1, flamebait) (Score:1)
hmm maybe if I say, "lusers drink milk so they need the link" wll that do?
Maybe ... (Score:2)
What goes around comes around.
DHTML and javascript (Score:5, Insightful)
Re:DHTML and javascript (Score:3, Interesting)
DHTML support is not that great and even then its a bit cumbersome to use than say Dreamweaver.
Frontpage is good for those building simple websites without much user configuration. DHTML usually does not figure in it.
Re:DHTML and javascript (Score:5, Informative)
One is complete and big, the other is more of a featherweight and a bit less powerful of course.
Re:DHTML and javascript (Score:5, Informative)
Re:DHTML and javascript (Score:2)
It appeared nearly all black. It worked in Internet Explorer. Do I have to say this is the most ironic thing on the Internet!!!
Re:DHTML and javascript (Score:2)
JavaScript Libraries (Score:2)
Keep JavaScript Simple [digital-web.com] By Peter-Paul Koch
Re:DHTML and javascript (Score:5, Interesting)
you can code round different browsers by implementing a common API for your applications and let your library do the platform specific work
I've done plenty of intranet javascipt applications, one of which is an HTML email composer.
It uses DHTML to drag and resize the html elements around. It works like Quark, you draw a square and type in the text.
Re:DHTML and javascript (Score:3, Insightful)
Language portability happens in C all the time, and is managed through a number of very difficult tools. In Javascript, it does it in runtime, figuring out its environment and adjusting which routines will run dynamically. In Java the environment provides the portability.
Portability is a worth-while goal in tha
Re:DHTML and javascript (Score:1)
Re:DHTML and javascript (Score:2)
<div style="width:500px; background:red;" id="red">Red</div>
<div style="width:500px; background:green;" id="green">Green</div>
<script language="javascript">
// this will hold a function
var mousehandling;
// my class
function Point(x, y) {
this.x = x
this.y = y
}
switch(navigator.appName) {
// lame browser detection
case "Microsoft Internet Explorer"
mousehandlin
Re:DHTML and javascript compatibility (Score:4, Informative)
DOM support has become widespread enough that you can easily create DHTML features on a page that will work for over 99% of your visitors. The worst thing so far has been some of the positioning properties; however, some of that is due to the surfeit of properties used by IE.
The Web Programmers Cross Reference (Score:1)
(yes, I am a No
Re:DHTML and javascript (Score:2)
If you can deprecate Netscape 4 and below and IE 5.0 and below (5.5 is generally OK), the incompatibilities really aren't all that bad. Newer versions of the "big two" are mostly standard-compliant, or at least compatible with each other.
There are a few annoyances such as different levels of support for CSS, but these are nothing compared to the nightmare that
Who needs a book? (Score:5, Interesting)
Re:Who needs a book? (Score:3, Informative)
It's a great reference, and makes it easy to look up all of the various HTML elements, CSS styles, and JavaScript objects.
The advantage is that it's all in one place, and I can read it while it's lying on my desk, and have a text editor window open to type in my code. It's a pain to constantly switch back and forth between two windows when you're in an intensive coding session -- well, it is for me at least.
It's like a dictionary. You can u
Re:Who needs a book? (Score:1)
Ok, so I was reluctant when I first picked up and started reading
Emphasis mine.
This comment pops up with every book review (Score:2)
Well, crap. Why *ever* use a book when the information is already available in electronic form? Why read Tom Sawyer in book form when you can read it on your Palm Zire? Why read the printed newspaper at the coffee shop, when it would be far more efficient to bring your laptop, look for a Wi-Fi network, and read the news online?
My point is that sometimes online sources are hampered by the medium. The book for all its faults is a wonderful inf
$4 less and free shipping! (Score:1, Informative)
Re:$4 less and free shipping! (Score:1, Informative)
Re:$4 less and free shipping! (Score:3, Insightful)
At least, don't mod them until they create t
Re:$4 less and free shipping! (Score:1)
Save $1.18 more and free shipping (Score:3, Informative)
Try Books-A-Million [booksamillion.com] and avoid supporting Amazon patents and non-privacy.
Re:bookpool is even cheaper (Score:2)
Re:$4 less and free shipping! (Score:2, Insightful)
Only five comments... (Score:1)
Just wondering if you ever get any nice scripts from that site...
Comment removed (Score:4, Funny)
dhtml demo (Score:2)
If you want a little demo of what you can do with dhtml, check out "Hau Strange" [netzgoetter.de] by the demoscene group Haujobb [haujobb.org]
Think you need modplug to get the music.
Re:dhtml demo (Score:2)
the wayback machine knows all [archive.org] of course it's ie only (hey it was 98, NS sucked balls), and the images are long dead as net-effect has been out of business for years.... but there my trumpet is blown
Re:dhtml demo (Score:2)
Nice.. Do you happen to know where I can find more dhtml "scene" related stuff?
I stumbled upon a nice dhtml 4 kb compo site some time ago (with everything from fractal zommers to raycasting engines), but I can't seem to find it with Google now.
Re:dhtml demo (Score:1)
Although I believe there is a "most obfusticated" C competition out there, too.
Re:dhtml demo (Score:1)
I've got a website I wrote, some time ago, which is written 99% in JavaScript (and DOM). See it here: Urgent [urgent.dk].
If anyone's interested, there's the link to my JavaScript TreeView [sf.net] (Open Source!) in my signature, so go ahead and try it out</advertising>.
JavaScript in a Linux Documentation Project (Score:1, Informative)
Even just a tips or suggestion to the author would be useful; TLDP is always looking for inputs to the projects and this is a recent project.
In the future everyone will have the INTERNET (Score:3, Funny)
"Often with CSS"? (Score:4, Interesting)
DHTML was coined, as the combination of HTML providing structure, CSS providing presentation, and JavaScript providing logic.
If you just use HTML and JavaScript, you're just doing a plain HTML page with logic (like form checkers).
I would also note, that JavaScript object are already hash tables, so "simulating hash arrays" isn't really needed (or I fail to see where it becomes relevant?)
object["myprop"] == object.myprop
There's only one book JavaScript programmers need, the rhino book. It's all in that. Everything else is just experience, and cannot be conveyed by a bunch of scripts. Or if it can convey something, it's most likely because said reader didn't catch it in the Rhino book
Definitive JS book... (Score:1)
Re:"Often with CSS"? (Score:1)
Re:"Often with CSS"? (Score:1, Informative)
I don't mean changin values in forms (you don't need the full power of DOM to do that), but changing anything present in a web page via the DOM model, which contains everything you can see on screen. I mean, there are wordprocessors out there pr
A Fan of Goodman's Books (Score:5, Informative)
The cookbook is great for newcomers to web development. It is based on common tasks, i.e. "Allowing Only Numbers (or Letters) in a Text Box". It then shows how to combine the HTML, CSS and Javascript to get carry out that task. I can't count how many times that a co-worker has asked me a Javascript question and I've shown them the answer straight out of that book. For programmers new to web development, the largest obstacle isn't HTML or Javascript syntax; it's how to put together those elements. I have yet to see a book that does it as clearly as the the JS and DHTML Cookbook. For someone starting out on their first web based projects, I'd strongly recommend DHTML - the Definitive Guide and the JS/DHTML cookbook as the best references for getting started.
Not JavaScript!!! (Score:3, Interesting)
BTW, can anyone spot the problem with this code:
function myfunc1()
{
for(i=0; i<10; i++) myfunc2(i);
}
function myfunc2(value)
{
for(i=0; i<15; i++)
}
Here's a hint for you. "i" in myfunc1() is not what you expect it to be.
Re:Not JavaScript!!! (Score:2)
Re:Not JavaScript!!! (Score:2)
Re:Not JavaScript!!! (Score:2)
Re:Not JavaScript!!! (Score:1)
What problem? (Score:3, Insightful)
Sure can. You redefine the variable i. Departing radically from /. convention, I actually pasted your code into my trusty text editor to see if there was some cool trick that I didn't notice just reading it & found that it behaved exactly as I expected:
In fact
Re:What problem? (Score:2)
Basically? Yes. The long answer is that you are never required to define your variables, thus producing the problem. You cannot run into this problem in C, because you'd have to define "i" first. If you're still using a global variable, then it's your own damn fault. It should be painfully obvious what the problem is in that ca
What is needed is DISCIPLINE! (Score:2)
The same could be said for Perl, except that there is "use strict". And "use strict" always brings to mind the image of a leather-clad female software engineer threatening the coders with a whip & chain... Ok, ok, so I'm a pervert ;-)
So, shall we tie up JavaScript kludgers & force them to
Re:Not JavaScript!!! (Score:4, Insightful)
a = 1 + 4 would yield a = '14'. Irritating.
Re:Not JavaScript!!! (Score:2)
a = 1 + 4 would yield a = '14'. Irritating.
Where (what browser) do you see that behaviour?
With a straight assignment:
a = 1 + 4;
'a' should yield 5.
If 'a' already contains string data and you append to it:
a = "";
a+= 1;
a+= 4;
then you'll end up with "14"
Though, if you do:
a = "";
a+= 1+4;
you'll end up with "5" because the numeric operation takes precedence over the assignment.
Not sure if all browsers will behave this way, but the Moz/Firebird js console bears this out.
Re:Not JavaScript!!! (Score:1)
This entire sub-thread of I-hate's can be paraphrased as "I hate it because it's different from what I use every day."
...which says more about the poster than the language being discussed.
Re:Not JavaScript!!! (Score:2)
Re:Not JavaScript!!! (Score:2)
a=1+'4' == '14'
a=1+'4'*1 == 5
Just *1 your strings
Re:Not JavaScript!!! (Score:2)
use var to give it a local scope.
ie. for(var i=0; i10; i++) myfunc2(i);
Re:Not JavaScript!!! (Score:2)
This isn't something a competent programmer should have a problem with anyway, though several of those out there using JS are far from what I'd call "competent programmers"....
Re:Not JavaScript!!! (Score:2)
If JavaScript actually required the programmer to define his variables, this problem would go away. The only time being able to create variables out of the blue worked,
Example code, for free (Score:4, Informative)
What IS DHTML anyway? (Score:3, Informative)
DHTML = Script manipulated HTML (Score:3, Informative)
While Dynamic HTML can be simplified as JavaScript + HTML + CSS, I can think of many instances where these technologies are use and it still can't be considered dynamic HTML.
Ex: Using JavaScript to validate a form is not DHTML.
DHTML - My definition
Dynamic HTML - Any HTML content that is either dynamically created or altered by a client-side scripting language such as JavaScipt or VBScript.
To put it simply: If you're changing the page layout on the fly, then you're doing Dynamic H
Re:DHTML = Script manipulated HTML (Score:1)
Actually, DHTML is a real and specific thing (Score:3, Informative)
Dynamic HTML is a real and valid term which covers:
1. Dynamically creating HTML on the client.
2. Dynamically altering HTML on the client.
You *ARE* doing Dynamic HTML if you are using JavaScript and CSS to *DYNAMICALLY* create/alter HTML on a page.
You *AREN'T* doing Dynamic HTML if your use of JavaScript and CSS neither creates or alters the HTML on a page.
In conclusion: Dynamic HTML is the process of dynamically creating and altering HTML in a web page.
(Sorr
Re:What IS DHTML anyway? (Score:2)
It's like Margaritaville. Somebody once asked Jimmy Buffett where the hell Margaritaville was & he said, "It's wherever you want it to be."
Some folks say DHTML is JavaScript-enhanced HTML. Others like to throw in a pinch of Perl or PHP with their JavaScript & cook it up like gumbo. Some add a smidgen of Flash while they're at it. And then they complain because nobody's browser will run it.
DOM detection is such a P.I.T.A. (and I don't mean middle easte
Is there work for a pure DHTML programmer? (Score:3, Interesting)
Re:Is there work for a pure DHTML programmer? (Score:2)
Re:Is there work for a pure DHTML programmer? (Score:1)
Re:Is there work for a pure DHTML programmer? (Score:1)
Re:Is there work for a pure DHTML programmer? (Score:1)
like i keep telling and proving to my boss, i can save a ton of logic and bandwidth on the backend by makeing
Re:Is there work for a pure DHTML programmer? (Score:1)
To do this kind of work requires a good understanding of DH
Sure! In web design, and JavaScript components (Score:3, Interesting)
You should also note the increasing growing market of selling JavaScript components like Dynamic Menus, Calendar Pickers, Tables, and other goodies.
Obviously DHTML is only half the solution for most problems, so we find that most DHTML programmers usually use DHTML in conjunction
Apples and oranges (Score:2)
Beware: This book is not for everyone... (Score:2, Interesting)
I bought this book, thinking that if it is anywhere near as useful as the Perl Cookbook, then I would be getting my US $39.95 worth. I was very disappointed with the book and would not recommend it to JavaScript/DHTML experts.
The problem with this book is that is almost completely tailored to the person who hasn't much experience with these technologies. For example, the section on the String object gives newbie tips like:
(Whoo-hoo! Thank you Danny Goodman, where c
Javascript nonstandard and nonproductive (Score:2)
Re:Javascript nonstandard and nonproductive (Score:1)
Come on... (Score:1)
DHTML Lemmings! (Score:2)
DHTML might be a good altervative to Java in the future for some web based interfaces, considering that a decent version of Java does not come with Internet Explorer anymore.
Re:DHTML Lemmings! (Score:1)
Re:the steps (Score:2, Funny)
Not Microsoft (Score:3, Informative)
DHTML itself is not a technology... it's simply a method of using existing technologies (javascript, CSS, HTML form elements, etc) to create client-side dynamic web pages.
Microsoft and Netscape both created implementations of DHTML which were largely incompatible with each other, leading to many programmer headaches.
W3C is working on a standard as we speak, which is largely dependent on the standardized Document Object Model.
More info...
http://www.talltech.com/student/imos
Re:Not Microsoft (Score:2)
Re:Not Microsoft (Score:1)
No argument there. But having something ratified by W3C is certainly a good thing. At least the standard will exist, so that we'll know exactly how Microsoft is violating it!
Re:Not Microsoft (Score:2)
Is this a time warp? Netscape deprecated layers with version 6.
I don't mind a defense of Microsoft, but please do it with 2003 examples!
BTW, http://www.talltech.com/student/imos98student/j_c h u/dhtml/standards.htm was /.ed or just plain not online. Looking at the URL, I'm led to believe this was a s
Re:Not Microsoft (Score:1)
The original poster was referring to the beginnings of DHTML, and I was clarifying on that point. This was the late 90's time frame.
And yes, the site did appear to go down inexplicably...
Re:Not Microsoft (Score:2)
Re:Vendor Specific (Score:1, Informative)
No one has to use microsoft DOM, in fact, all vendor specific DOMS are being phased out in preference to the W3C model.
From w3c.org:
"Dynamic HTML" is a term used by some vendors to describe the combination of HTML, style sheets and scripts that allows documents to be animated. The W3C has received several submissions from members companies on the way in which the object model of HTML documents should be exposed to scripts. These submissions do not propose any new HTML tags or style sheet tec
Re:Vendor Specific (Score:2)
How on Earth was this modded up as informative? Sure, it informs us that rossz is totally ignorant about this subject, but DHTML is definitely NOT a "Microsoft creation". Netscape 4 had DHTML capabilities well before the first capable MS browser (IE4) appeared.
DHTML stands for "Dynamic HTML". It's the result of manipulating the browser DOM using a scripting language (virtually always Javascript).
Re:Vendor Specific (Score:2)
Nonetheless, DHTML itself -- that is, combining JavaScript, HTML, and CSS -- isn't proprietary at all.
And you can still follow web standards when using DHTML techniques.
Everything I've ever done using DHTML works on Netscape Navigator 4 through the current versions of Mozilla and Safari, which as far as I know are about as standards-based as you can get.
The point is, DHTML is useful. Without it, there are a lot of things that you simple ca