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.

Chapter 2 ✦ Window and Frame Objects (Chapter 16)<br />

Example<br />

Use The Evaluator (Chapter 13 in the <strong>JavaScript</strong> <strong>Bible</strong>) to experiment with the<br />

screenX and screenY properties in NN6. Start with the browser window maximized<br />

(if you are using Windows). Enter the following property name into the top<br />

text box:<br />

window.screenY<br />

Click the Evaluate button to see the current setting. Unmaximize the window and<br />

drag it around the screen. Each time you finish dragging, click the Evaluate button<br />

again to see the current value. Do the same for window.screenY.<br />

scrollX<br />

scrollY<br />

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

Compatibility ✓<br />

Example<br />

Use The Evaluator (Chapter 13 in the <strong>JavaScript</strong> <strong>Bible</strong>) to experiment with the<br />

scrollX and scrollY properties in NN6. Enter the following property into the top<br />

text box:<br />

window.scrollY<br />

Now manually scroll the page down so that you can still see the Evaluate button.<br />

Click the button to see how far the window has scrolled along the y-axis.<br />

self<br />

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

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

Example<br />

Listing 16-16 uses the same operations as Listing 16-5 but substitutes the self<br />

property for all window object references. The application of this reference is<br />

entirely optional, but it can be helpful for reading and debugging scripts if the<br />

HTML document is to appear in one frame of a multiframe window — especially if<br />

other <strong>JavaScript</strong> code in this document refers to documents in other frames. The<br />

self reference helps anyone reading the code know precisely which frame was<br />

being addressed.<br />

149<br />

windowObject.self

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

Saved successfully!

Ooh no, something went wrong!