Animated Ball UMUC Logo
http://polaris.umuc.edu/~flazarus/

JavaScript Placement

There are two types of JavaScripts, delayed and immediate. Delayed scripts are placed within the <head> tags and immediate scripts within the <body> tags. The delayed scripts are called one or more times from constructs placed within the body tags. Immediate scripts execute when the browser reaches their placement point on the page. An example of a call to a delayed script is shown below.

An example of an immediate script can seen as the 'last update' script that I use on most pages.

A variation on an immediate script that is included within the <head> tags rather than within the <body> tags is the 'no capture' script that I often use. This approach is used when you want the script to execute before the page writes. This is an implicit onLoad event handler.

One additional note. JavaScripts can be written as separate files with .js extensions and called or can be explicitly written into the HTML page. I use the former approach for scripts that I use very often on my pages. The 'last update' is an example of this.

Please click 'view' to see these constructs. Note: If you are using Netscape you will see only the result of the 'last update' script. An unfortunate 'feature' of Netscape.

You might want to consider taking a JavaScript class. See: Programming with JavaScript.

To Index