[an error occurred while processing this directive]

Site Menu

HTML
Learn all about HTML, how to format text, add images, create tables, meta taga, and more!
.
JavaScript
Get the low down on JavaScript. See how to create popular JavaScript applications like drop down menus, clocks, dynamic messages, popup boxes, and more.
.
CGI
Concise, easy to follow introdction to CGI and how to install CGI scripts.
.
Web Design
A miscellanous section that includes various web design tutorials

 

123 Web Design!

on-the-fly messages

Text inside the document is usually static- if you reload this document 5 times, there's no reason to believe that the document's text will be any different each time...or is there? One of the coolest things about JavaScript is that it allows you to generate text on the fly. You could, for example, have the document greet you "Good morning" in the morning, and "Good night" at night. The basic way to write out text in JavaScript is by using the document.write() command, as follows:

<script>
document.write('Some text')
</script>

Whatever you put inside the parentheses, JavaScript displays it on the page. Taking this basic idea one step further, I'll create a script that writes out the last modified date of this page.

<script>
var modifieddate=document.lastModified
document.write(modifieddate)
</script>

08/07/2001 02:26:24

The above is a perfect example of "on-the-fly" text. The text  reflects the last modified date of your page, and is updated automatically whenever you edit the page and save it!