Javascript
Jeff Williamson
Northern Virginia Community College
www.nvcc.edu/home/nvwillj/html-graphics/
nvwillj@nvcc.edu
Page information
Before we begin- If you're looking at this page on www.nvcc.edu,
a lot of the info will be wrong. It has to do with that server and these
scripts - some more info is given later on in this page. Check out the
mirror
of this page on classweb.gmu.edu - same page, same scripts, right info.
The test page I loaded on several servers
might also be interesting. Also, Netscape 3 users won't see the scripts
- NN3 has problems with Javascripts in tables. - jw
A good practice in HTML authoring is to include some information on
your page about its creation. This information can include
- last updated date
- date accessed
- document URL
- author's name and contact
1 and 4 are commonly used. 2 is required for academic citations,
so as an English teacher, I recommend it. 3 is often taken
care of with browser print functions, but not always. Having the
URL display in the body is the only reliable way to ensure that users
always have it in printouts.
Javascripts have the technical capacity to display 2, 3, and 4. However
the accuracy of their results varies with server and computer differences.
Following are scripts for providing page information and discussion
of their pitfalls:
1. Last updated
The script above should read something like
Last updated: 07/14/99 20:49:58
The script for it is this:
<script
language="Javascript">
document.writeln("Last updated: " + document.lastModified)
</script>
A neater display can be had with slightly longer code. Example
The script for it is this:
<SCRIPT
LANGUAGE="JavaScript">
<!--Begin
var m = "Page updated " + document.lastModified;
var p = m.length-8;
document.write(m.substring(p, 0));
// End -->
</script>
If the code above does not display correctly (and it won't on the server
for www.nvcc.edu), here are some things that can go wrong:
Date is blank: Many Javascripts don't work well in tables -
and this page is laid out in a table.
Date is for 1969: According to Laura LeMay, this is a server
problem
Date is in future or some non-1969 date: This seems related
to individual computer differences. I've seen this in classes,
where 25 students are looking at my pages, and 4 have dates that are
different from the other 21.
2. Date accessed
The same trials for last updated scripts apply to today's date scripts.
Today's date is
The script can be viewed in a separate
window.
3. Document URL
This script should be included for any page that is likely to be printed,
since browsers do not reliably print the complete addresses of pages.
The script for the above is
<script
language="JavaScript">document.writeln("The URL of this page is "
+ document.URL)</script>
Note: People often want script-generated material to have the
same font characteristics as other text on the page. Mostly this
won't happen; computer-generated information always uses default settings,
similar to the way the numbers in the list below are black, even thought
the items are surrounded by red font tags:
- item one
- item two
|