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 />

The window.routeEvent() method is used in the example for<br />

window.captureEvents(), Listing 16-21.<br />

scroll(horizontalCoord, verticalCoord)<br />

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

Compatibility ✓ ✓ ✓ ✓ ✓ ✓<br />

Example<br />

To demonstrate the scroll() method, Listing 16-31 defines a frameset with a<br />

document in the top frame (Listing 16-32) and a control panel in the bottom frame<br />

(Listing 16-33). A series of buttons and text fields in the control panel frame directs<br />

the scrolling of the document. I’ve selected an arbitrary, large GIF image to use in<br />

the example. To see results of some horizontal scrolling values, you may need to<br />

shrink the width of the browser window until a horizontal scrollbar appears in the<br />

top frame. Figure 2-9 shows the results in a shrunken window with modest horizontal<br />

and vertical scroll values entered into the bottom text boxes. If you substitute<br />

scrollTo() for the scroll() methods in Listing 16-33, the results will be the<br />

same, but you will need version browsers at a minimum to run it.<br />

Listing 16-31: A Frameset for the scroll() Demonstration<br />

<br />

<br />

window.scroll() Method<br />

<br />

<br />

<br />

<br />

<br />

<br />

Listing 16-32: The Image to Be Scrolled<br />

<br />

<br />

Arch<br />

<br />

Continued<br />

169<br />

windowObject.scroll()

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

Saved successfully!

Ooh no, something went wrong!