JavaScript and DHTML Cookbook
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.
... when a 500 page book is described as "compact".
People who disagree with you are not automatically evil, greedy, or stupid.
try this site instead:
http://www.irt.org/index.htm
if you need more help, you should try marketing instead.
Who took my tinfoil hat?
DHTML and javascript make an excellent combination for displaying animated content.. but the question of browser incompatibilty still remains... What we need is a book for making browsers compatible first then have lots of books on the ways to use them... seems logical to me anyway :-)
Seriously, who needs a javascript and dhtml book with all of the references on the net? Just give me a nice object reference for DHTML (*cough*, MSDN isn't bad.. i hate to admit it) and DevGuru's JavaScript reference.
My sig can beat up your sig.
Amazon has it for $4 less and with free shipping
...and the DynamicDrive site gets so slow you might think it's being slashdotted.
Just wondering if you ever get any nice scripts from that site...
-- Power corrupts, but PowerPoint corrupts absolutely.
Comment removed based on user account deletion
If you want a little demo of what you can do with dhtml, check out "Hau Strange" by the demoscene group Haujobb
Think you need modplug to get the music.
How small a thought it takes to fill a whole life
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.
DHTML? I'm having flashbacks to 1996.
_nfotxn
"often with CSS"? That doesn't even make sense.
;)
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
Har de har har, a self fulfilling luser :-) :-)
Infuriate left and right
I got the first Dynamic HTML when it came out then bought the second edition and the JS/DHTML cookbook.
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.
I can karma whore too :-)
Try Books-A-Million and avoid supporting Amazon patents and non-privacy.
Infuriate left and right
DHTML is a Microsoft creation and is not part of any recognized standard. Using it only perpetuates the ongoing attempt to control the internet through proprietary extensions.
If you don't think this is a bad thing, then go ahead and use DHTML. While you're at it, toss in some vbs to really screw things up.
-- Will program for bandwidth
Personally, I tend to dislike JavaScript. It has its uses, but JS programs quickly turn into huge messes that Anderson himself couldn't debug. Of course, most of these problems stem from the lack of engineering that goes into most Javascript code. If you define clear APIs (like any good engineer should) Javascript ends up being not half bad.
//do something;
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.
Javascript + Nintendo DSi = DSiCade
The book has a compatibility legend for each recipe; most of the recipes work with IE 4 and NN 4.
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.
BTW, you can download example code for this book from here.
I was under the impression that DHTML was just a buzzword. And that when anyone was talking about DHTML what they really meant was HTML pages with JavaScript or VBScript in them to make them do more than static HTML. Am I correct? If I'm wrong - than what the hell is DHTML?
Conserve Oil, Recycle, Boycott Walmart
1.Everyone type as root: rm -rf / C:\>rm -rf / 'rm' is not recognized as an internal or external command, operable program or batch file. C:\> Windows is apparently not vulnerable to your 1337 social enginner hax0ring techniques.
And here is the referral-free link. (I got the URL right this time.)
This guy does this in every book review- he posts an Amazon link quietly incorporating his referral ID, and it immediately gets an "Informative". Leech.
I do not think there is work for someone to do DHTML programming. Everything I have seen is going to servlets. Nobody is putting up static pages (No matter what anyone says, JavaScript does not make a page dynamic). Why pay someone 20 dollars an hour in today's market when there are hardcore programmers unemployed, who can write Java servlets and JSP?
Rosco: "If brains were gunpowder, Enos couldn't blow his nose."
or rather, not JUST microsoft.
_ ch u/dhtml/standards.htm
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/imos98student/j
Microsoft's existing standard will be very close to the final W3C standard. Netscape's was even more proprietary because it introduced new tags that are not even in the HTML 4.0 standard (Layers, anyone?)
-CausticPuppy "Of all the people I know, you're certainly one of them." -Somebody I don't know
... I drink milk :-)
What goes around comes around.
Infuriate left and right
What DHTML is not
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 HTML.
"Communism is like having one [local] phone company " - Lenny Bruce
Would someone please point to a URL with the
source code (for research purposes only)
Very truly yours,
Jon_Katz's_Commodore_64_programmer_in_Afg
sorry not funny.
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:
- myfunc1() passes 0 (zero) to myfunc2() on the first iteration of the myfunc1 loop.
- myfunc2() then increments i stepwise to 14 whereupon it returns to myfunc1() & ends because 14 > 10.
In fact, this same code (with slight syntax changes) produces the same result in Perl unless 'i' is localized in each function & the value passed to myfunc2 is handled as @_. I'm pretty certain the result would also be the same in C, but here I bow to laziness &Are you trying to illustrate the sloppy code that happens because JavaScript is easy & free & a bunch of folks with no concept of good coding practice can just kludge away? Or is there something more substantive to the example?
"Obviously, I'm not an IBM computer any more than I'm an ashtray" (Bob Dylan)
(yes, I am a No Starch Press employee)
Hyperic Community Manager
Hyperic Community Manager
Ummm no. DHTML refers to the ability to change the properties of HTML elements dynamically. You can USE JavaScript to change the properties of HTML elements. But you could also use VBScript, or any scripting language that allows you to modify the document object model.
I've always found that learning from actual example programs or source is one of the quickest and best ways to learn.
Anyone looking at enhancing their javascript or DHTML should take a look at Oddpost and Convea which are two of the best web applications using javascript and DHTML.
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 submit to some form of "use strict"? Discipline is what they need! Heck, I might write some bad code just to meet that leather-clad supervisor!
"Obviously, I'm not an IBM computer any more than I'm an ashtray" (Bob Dylan)
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 can I mail my check to?)
In this very same section on String concatenation it completely fails to discuss the geometric performance loss experienced as strings become larger and larger. Why wouldn't you discuss this? What I would expect to see is a discussion of how you can implement your own version of a StringBuffer, similar to Java, by using Array operators.
There is almost no discussion of client-side XML, absolutely nothing on XSL. If you do much dynamic in-place refresh of data or styles, this book will not help you much.
The book might be fine for novices and maybe even intermediate developers, but for experts it falls very flat. I skim the book once a week or so hoping to glean something new, and I'm always disappointed. Caveat Emptor.
If you are a serious developer you should probably just have your employer buy you a subscription to the O'Reilly Safari online bookshelf, and then you can see for yourself whether or not this book is any help to you.
(BTW, for those have said that you cannot get work as a DHTML programmer, you are so wrong. I make a comfortable six-figure salary doing this work for governments and large corporations. If you are good enough at what you do you can always find someone willing to pay you for it, and DHTML is no exception.)
To the best of my knowledge Javascript is not a standard language approved by a "standards" making body (e.g. ANSI, ISO, etc.). It will also routinely crash or cause errors in Netscape browsers and/or suck up CPU time better devoted to distributed computing projects. The reasonable thing for an intelligent user to do is to browse the web with Javascript disabled. Who knows what security holes may lurk in Javascript code? More information on why not to use Javascript and how to write code that makes the clients happy (i.e. it downloads fast) is here.
...how much did they pay you to write this review ? I mean, it's probably a good book, but who needs a book on JavaScript ? There's plenty of info on the web; I can't think of _any_ book that's worth buying when it comes to mainstream software development. Dead tree format study guides are so 20th-century...
So after reading this book, would I be able to do something like this ?
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.
I don't you followed my definition:
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.
(Sorry for being super-redundant)
"Communism is like having one [local] phone company " - Lenny Bruce
DHTML Lemmings is awesome!
I've found that there is a growing demand for web designers who can use DHTML as an alternative to Flash, especially considering most of today's web-browsers have become considerable more compatible in the last few years.
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 with ASP, PHP, JSP or some other server-side technology.
Not to mention the learning curve from something like JavaScript to PHP is fairly short. So the incentive to isolate oneself in a DHTML-only world is probably slim.
"Communism is like having one [local] phone company " - Lenny Bruce
Here's all the javascript you need:
<script>
s = "Javascript sucks asteroids thru pipettes!";
while ( true ) {
alert("Are you having fun yet?");
s += s + s;
}
</script>
"Why use a book when x,y,z is available for free on the Internet?
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 information vector. It's not always best, but it's often worth paying money for; even in the digital age.
Read the EFF's Fair Use FAQ
There are some things that are just plain clunky to do server-side. Maybe programmers don't understand the value of client-side scripting--obviously you don't, but users (as long as you have a noscript alternative) and sysadmins certinaly do.
Bookpool has it for less than Amazon, BN, or booksamillion. They have free shipping if your order is $40 or more, so this may or may not be a better deal.
Hyperbole is the worst thing ever.
I've banished DHTML and all it encompasses. XWT is what I use now... No browser bugaboos, straight JavaScript, OSS, multiplatform, fast, client/server and perfectly clear separation of content from presentation.
Screw DHTML. XWT is the future.
Comment removed based on user account deletion
thanks, well, it has been a while
There are places where the networks are not touching,and there are places where they are-Boeing's Lori Gunter
And you nicked my sig
That's very perceptive of you Mr Stapleton and rather unexpected in a G Major
I appreciate your insightfulness on this book. I am currently finishing up on a core req. class on HTML. I am anxious to move on. Jazz
A good anti-JavaScript Libraries article:
Keep JavaScript Simple By Peter-Paul Koch
Phillip