Document Object Model

We can’t talk about JavaScript without mentioning the DOM, an important concept to understand about how javascript works. The Document Object Model or DOM provides a structural representation of an HTML or XML document, enabling us to modify its content and visual presentation. Essentially, it connects web pages to scripts or programming languages or alternately, one could say it’s our window into modifying HTML pages programatically (on the fly).

Here’s a really simple bit of code:

		document.write("Hi there.")

In this code, document is the object. write is the method of this object. Let’s have a look at some of the other methods that the document object possesses.

You can always include the last update date on your page by using the following code:

		 

All you need to do here is use the lastModified property of the document. Notice that we used + to put together This page created by John N. Last update: and document.lastModified.

Lets try playing around with bgColor and fgColor:

		 
	

Next up: Message Boxes


Posted

in

,

by

Tags:

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *