Web design course - 315Chapter 15Generic HTML Element Objectsto the parent of

315Chapter 15Generic HTML Element Objectsto the parent of the uland olobjects: the document.body. Also, you need to change thedocument.allreferences to document.getElementById(). Related Items:removeChild(), removeNode(), replaceChild(), swapNode()methods. scrollIntoView(topAlignFlag) Returns:Nothing. Compatibility:WinIE4+, MacIE4+, NN7+, Moz1+, Safari- The scrollIntoView()method scrolls the page (vertically and/or horizontally as needed) such that the current object is visible within the window or frame that contains it. A singleparameter, a Boolean value, controls the location of the element within the viewable space. Avalue of true(the default) causes the element to be displayed so that its top is aligned withthe top of the window or frame (provided the document beneath it is long enough to allowthis amount of scrolling). But a value of falsecauses the bottom of the element to align withthe bottom of the viewable area. In most cases, you want the former so that the beginning ofa page section is at the top of the viewable area. But if you don t want a user to see contentbelow a certain element when you jump to the new view, use the falseparameter. For form elements, you must use the typical form element reference (document.formName. elementName.scrollIntoView()) unless you also specify an ID attribute for the element(document.getElementById( elementID ).scrollIntoView()). ExampleUse The Evaluator (Chapter 13) to experiment with the scrollIntoView()method. Resizethe browser window height so that you can see only the topmost text box and the Resultstext area. Enter each of the following statements into the top text box and see where the myPelement comes into view: myP.scrollIntoView() myP.scrollIntoView(false) Expand the height of the browser window until you can see part of the table lower on thepage. If you entermyTable.scrollIntoView(false) into the top text box, the page scrolls to bring the bottom of the table to the bottom of thewindow. But if you use the default parameter (trueor empty), myTable.scrollIntoView() the page scrolls as far as it can in an effort to align the top of the element as closely as possi- ble to the top of the window. The page cannot scroll beyond its normal scrolling maximum(although if the element is a positioned element, you can use dynamic positioning to place itwherever you want including off the page ). Also, if you shrink the window and try toscroll the top of the table to the top of the window, be aware that the tableelement containsa captionelement so the caption is flush with the top of the window. Related Items:window.scroll(), window.scrollBy(), window.scrollTo()methods. setActive() Returns:Nothing. Compatibility:WinIE5.5+, MacIE-, NN-, Moz-, Safari- The setActive()method lets a script designate an element object as the active element. However, unlike the focus()method, the window does not scroll the active element intoelementObject.setActive()