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.

146<br />

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

To gain an understanding of how the offset values work, scroll the window<br />

slightly in the horizontal direction and notice that the pageXOffset value<br />

increases; the same goes for the pageYOffset value as you scroll down. Remember<br />

that these values reflect the coordinate in the document that is currently under the<br />

top-left corner of the window (frame) holding the document. You can see an IE4+<br />

version of this example in Listing 18-20 (in Chapter 4 of this book). A cross-browser<br />

version would require very little browser branching.<br />

parent<br />

windowObject.parent<br />

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

Compatibility ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓<br />

Example<br />

To demonstrate how various window object properties refer to window levels in<br />

a multiframe environment, use your browser to load the Listing 16-14 document. It,<br />

in turn, sets each of two equal-size frames to the same document: Listing 16-15. This<br />

document extracts the values of several window properties, plus the<br />

document.title properties of two different window references.<br />

Listing 16-14: Framesetting Document for Listing 16-15<br />

<br />

<br />

The Parent Property Example<br />

<br />

self.name = “Framesetter”<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

Listing 16-15: Revealing Various Window-Related Properties<br />

<br />

<br />

Window Revealer II<br />

<br />

function gatherWindowData() {<br />

var msg = “”

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

Saved successfully!

Ooh no, something went wrong!