Sams Teach Yourself Web Publishing with HTML and CSS in One Hour a Day (5th Edition)

This workshop includes some questions you might have, a quiz about some of today's most important topics, and some exercises you can do to reinforce your knowledge of DHTML.

Q&A

Q

Is DHTML really worth the time and effort?

A

DHTML is the key to web applications taking on the functionality of desktop applications. If you use applications such as Google Mail, Yahoo! Mail, or any of the online mapping services, you'll see DHTML used in many ways to make the applications more interactive than the typical web page. If you're working on an application that would benefit from giving the user instant feedback in the user interface, then learning DHTML is for you. If you're publishing a static website, you can probably skip it.

Q

There's so much information to learn. How do I do it?

A

First, start with HTML. Become an expert in it!

After that, you could take either of two approaches: master everything or learn only what you need.

The "master everything" approach leads you, in succession, from HTML to CSS, and then to JavaScript, moving on only when you're competent and comfortable with the technology at hand. After you master all three technologies, study how they interrelate and try your hand at DHTML.

The "learn only what you need" approach gets you started more quickly. Find a specific technique that you want to use, such as dynamically changing the visibility of an object, and learn how to do that. After you finish, go on to the next technique that you find interesting. You'll learn a little bit about all the technologies along the way, but will have DHTML to show for it almost immediately.

You might also want to find DHTML code on sites around the Web and see how it works. Although most code is protected by copyright, there's certainly nothing wrong with reviewing it and applying the concepts to your own work.

Q

What about Netscape's LAYER element and other browser-specific DHTML features?

A

As far as I'm concerned, cross-browser DHTML is where it's at if you're going to bother with DHTML at all. If you want to reach the greatest number of people (and offend the fewest), you should concentrate on creating web pages that are (relatively) universal. I admit that these proprietary web browser features can be very tempting, and that some of the effects are pretty neat; however, there's nothing more frustrating than spending weeks developing a cool DHTML web page and finding out that most people can't even see it.

Quiz

1.

Which three technologies make Dynamic HTML possible?

2.

What is a Document Object Model?

3.

Can you use VBScript or another scripting language to create DHTML?

4.

What's the most important element of cross-browser DHTML?

5.

Which XmlHttpRequest ready state is the most important?

Quiz Answers

1.

HTML, cascading style sheets, and scripting.

2.

DOM is the language you use when you refer to scriptable objects on a web page.

3.

Yes, but you should know that VBScript isn't supported in Netscape Navigator without a special plug-in. Other scripting languages are even less supported. JavaScript is your best choice.

4.

Undoubtedly, the capability detection. This enables you to support not only today's browsers, but also browsers that haven't been released yet.

5.

State 4 is the most important, because it indicates that the request is complete and the data returned by the request is ready for you to use on your web page.

Exercises

1.

Create a list and let users add items to it by entering them in a text field, and remove items from it by clicking on them. (You'll need to add an onclick handler to your list items.)

2.

Create a <div> that only appears when you move the mouse over a particular element on a page.

3.

Copy the pull-down menu example and add a second menu.

Категории