Objects in Javascript

This page demonstrates some uses of objects in Javascript. First, a method of the Javascript String object is used to split the user input into separate words. Next, the length attribute of the Array object is used to count the words in the sentence. Finally, the count is reported in a form input text box, and the sentence replaces Paragraph 1. The document object model is used to access and change elements in the document, using non-standard methods that are only supported by Internet Explorer.


Type in a sentence and click "submit."


Paragraph 1:

Watch what appears in this paragraph when you click "submit"


Paragraph 2:

Look at the source of this page, and notice that "id" is used rather than "name" to label the elements of the XHTML document. The "name" attribute is deprecated in XHMTL 1.0, and will be replaced completely by "id" in XHTML 1.1. If you want to make sure your pages work both with old browsers and with new XHTML engines, include both (as was done for this paragraph).

Click here to validate this document's XHTML