15.02.2013 Views

JavaScript Examples Bible - UserWorks Technologies

JavaScript Examples Bible - UserWorks Technologies

JavaScript Examples Bible - UserWorks Technologies

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

236<br />

document.layers<br />

<strong>JavaScript</strong> <strong>Examples</strong> <strong>Bible</strong>: The Essential Companion to <strong>JavaScript</strong> <strong>Bible</strong><br />

Example<br />

Experiment with the document.lastModified property with Listing 18-6. But<br />

also be prepared for inaccurate readings if the file is located on some servers or<br />

local hard disks.<br />

Listing 18-6: document.lastModified Property in Another<br />

Format<br />

<br />

<br />

Time Stamper<br />

<br />

<br />

GiantCo Home Page<br />

<br />

update = new Date(document.lastModified)<br />

theMonth = update.getMonth() + 1<br />

theDate = update.getDate()<br />

theYear = update.getFullYear()<br />

document.writeln(“Last updated:” + theMonth + “/” + theDate + “/” + theYear +<br />

“”)<br />

<br />

<br />

<br />

<br />

As noted at great length in the Date object discussion in Chapter 36 of the<br />

<strong>JavaScript</strong> <strong>Bible</strong>, you should be aware that date formats vary greatly from country<br />

to country. Some of these formats use a different order for date elements. When you<br />

hard-code a date format, it may take a form that is unfamiliar to other users of your<br />

page.<br />

layers<br />

Compatibility ✓<br />

NN2 NN3 NN4 NN6 IE3/J1 IE3/J2 IE4 IE5 IE5.5<br />

Example<br />

Listing 18-7 demonstrates only for NN4 how to use the document.layers property<br />

to crawl through the entire set of nested layers in a document. Using reflexive<br />

calls to the crawlLayers() function, the script builds an indented list of layers in

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!