What HTML Isn't
HyperText Markup Language (HTML) thrives in a static environment. You put up a page, then it pretty much stays where it is until the user calls up a new page, for example by clicking on a link. HTML lets you combine text and graphics, and gives you tools such as frames and tables to get the layout just the way you want it. HTML is pretty, but it ain't smart. If you need to process information (such as data entered into a form) you have to send it over the data stream back to your server (very smart), which then generates a new HTML page and sends it back to the user for display.
The Object Model
Let's look at how we can put these components to practical use to improve the interface of three sample HTML pages. In each case our goal will be to provide dynamic, context sensitive information to the user that is over and above what is included in the text of the page itself. The first example will employ the status bar to emphasize important information on the screen. The second example will bring up an alert box. The third example will bring up an entire window of information in response to the user clicking on a button. Be especially careful not to make a typo. Program commands must be typed in precisely or an error is likely to occur. If you learn best by doing, I've added some suggested exercises throughout the article that will help you make sure you understand the concepts. (Editor's Note: Click here to enter Heidi's mini-menu of sample programs and links, while here is a zipped file of all the sample code modules.)
Example 1: The Status Bar Application
refer to the contents of the status bar, which we can either read from or write to. If you've programmed before, it may help to think of this kind of expression as a variable. If you haven't programmed before, the important thing to know is that in order to assign a value to a variable or in this case a property you write a command that looks like this:
propertyName = propertyValue
where propertyName is the name of the property and propertyValue is an expression that evaluates to a valid value for propertyValue to contain. An expression can be the result of an equation, the value of another variable or property, or a literal value, such as a series of characters enclosed in quotation marks.
window.status = "Click here to download the compressed Mac version of Ziffle Zot."
is a valid expression, as is:
window.status = "The old status was " + window.defaultStatus
Note the way you can combine elements, in this case by concatenating a string of characters and another property value by using the plus sign.
Part 2 > ]