281Chapter 16 .Window (How to cite a web site) and Frame Objects document s 0,0
281Chapter 16 .Window and Frame Objects document s 0,0 point can move via manual or scripted scrolling. Although scroll() is a window method, it seems to behave more like a document method, as the document appears to reposition itself within the window. Conversely, you can also think of the window moving to bring its 0,0 point to the designated coordinate of the document. Although you can set values beyond the maximum size of the document or to negative values, the results vary from platform to platform. For the moment, the best usage of the window.scroll()method is as a means of adjusting the scroll to the very top of a document (window.scroll(0,0)) when you want the user to be at a base location in the document. For vertical scrolling within a text-heavy document, an HTML anchor may be a better alternative for now (though it doesn t readjust horizontal scrolling). On the CD-ROM Example (with Listings 16-31, 16-32, and 16-33) on the CD-ROM Related Items: window.scrollBy(), window.scrollTo() methods. scrollBy(deltaX,deltaY) scrollTo(x,y) Returns: Nothing. NN2 NN3 NN4 NN6 IE3/J1 IE3/J2 IE4 IE5 IE5.5 Compatibility . . . NN4+ and IE4+ provide a related pair of window scrolling methods. The window.scrollTo() method is the new version of the window.scroll() method. The two work identically to position a specific coordinate point of a document at the top-left corner of the inner window region. In contrast, the window.scrollBy()method allows for relative positioning of the document. Parameter values indicate by how many pixels the document should scroll in the window (horizontally and vertically). Negative numbers are allowed if you want to scroll to the left and/or upward. The scrollBy()method comes in handy if you elect to hide the scrollbars of a window or frame and offer other types of scrolling controls for your users. For example, to scroll down one entire screen of a long document, you can use the window.innerHeight(in NN) or document.body.clientHeight (in IE) properties to determine what the offset from the current position would be: // assign IE body clientHeight to window.innerHeight if (document.body && document.body.clientHeight) { window.innerHeight = document.body.clientHeight } window.scrollBy(0, window.innerHeight) windowObject.scrollBy()
If you are in need for cheap and reliable webhost to host your website, we recommend http web server services.