HTML and CSS Reference
In-Depth Information
Summary
This lesson demonstrated a number of common tasks associated with programming in
JavaScript. It illustrated how to access the values in forms and check them for errors. It
also explained how you can manipulate the styles on a page and even the contents of a
page using JavaScript. The final two examples were written in a style referred to as
unobtrusive JavaScript, which involves writing JavaScript in such a way that the page
still works even if the user has disabled JavaScript, or their browser does not offer
JavaScript support. JavaScript is used to enhance the user's experience, but the function-
ality of the page is not dependent on JavaScript. This approach is generally favored as
the preferable way to write JavaScript these days. It separates JavaScript code from the
markup on the page and ensures support for the largest number of users, including users
with mobile browsers that may not support JavaScript functionality.
In the next lesson, I demonstrate how to perform some of the same kinds of tasks as I did
in this lesson using the popular JavaScript library jQuery, and explain the role jQuery
and other libraries like it can play in making it easier to add JavaScript functionality to
web pages.
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 Is there a way to incorporate form validation into my page so that errors are
displayed in the form rather than in a pop-up?
A Yes, using the techniques shown in the other examples in this lesson, you could
modify the document itself when validating the form. The trick is to modify the
DOM after validating the values, as opposed to displaying the message using the
alert() method. In the next lesson, I provide an example of how to display errors
in forms themselves using a JavaScript library.
 
 
 
Search WWH ::




Custom Search