Workshop


The following workshop includes questions, a quiz, and exercises related to the uses of JavaScript.

Q&A

Q

Can you point me in the direction of more scripts that I can integrate with my pages?

A

Sure, there are lots of sites with prepackaged JavaScript programs that you can use on your pages. You might try The JavaScript Source at http://javascript.internet.com/, or JavaScript.com at http://www.javascript.com/.

Q

I've seen the source for other image rollover scriptswhy are they so different from the one in this lesson?

A

Image rollovers are one of the most popular uses of JavaScript, and over the years, opinions on how to write the perfect image rollover have changed. Plus, the bottom line is that there's more than one way to do it. As long as the script works in the browsers that the person who wrote the script cares about, it works. The technique demonstrated in this lesson will work fine, but if you see a script out there that you like better, feel free to use it instead.

Quiz

1.

What's an inline <script> tag?

2.

What happens whenever a user clicks a link, button, or form element on a web page?

3.

What's the this statement?

4.

How can arrays streamline a script?

5.

How does form validation with JavaScript conserve server resources?

Quiz Answers

1.

An inline <script> tag is one that is embedded in the <body> section of an HTML document rather than in the <head> section, as is the more common practice.

2.

Whenever a user clicks a link, a button, or any form element, the browser generates an event signal that can be trapped by one of the event handlers mentioned in Lesson 2, "Preparing to Publish on the Web."

3.

The this statement is a special value that tells JavaScript to reference the current object without having to worry about its exact name or location.

4.

With arrays, you can create a single list of variables that are all referenced by the same variable name.

5.

JavaScript enables you to do error checking in forms on the browser side before the form is ever submitted to the server. A CGI script must access the server before it can determine the validity of the entries on a form. (Note that even if you use JavaScript form validation you must validate user input on the server as well, because users can bypass the JavaScript if they choose.)

Exercises

1.

Add new links to your list of random links in Exercise 13.3 by increasing the value assigned by new MakeArray( value ) and adding the new links to the list following the array elements already defined.

2.

Take the registration form example used in Exercise 13.4 and see whether you can adapt it to a form of your own on your own website.




Sams Teach Yourself Web Publishing with HTML and CSS in One Hour a Day
Sams Teach Yourself Web Publishing with HTML and CSS in One Hour a Day (5th Edition)
ISBN: 0672328860
EAN: 2147483647
Year: 2007
Pages: 305

Similar book on Amazon

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net