asp.net.ph

Skip Navigation Links

scrollIntoView Method

DHTML Methods


Causes the object to scroll into view, aligning it at either the top or bottom of the window.

Syntax

object.scrollIntoView (  [ bAlignToTop ] ) 
Parameters

bAlignToTop Optional. Boolean value specifying whether to place the object at the top of the window or at the bottom. If true, the method causes the object to scroll so that its top is visible at the top of the window. If false, the bottom of the object is visible at the bottom of the window. If no value is specified, the object scrolls to the top by default.

Return Value

No return value.

Example

The following example causes the element to scroll into view within the window, placing it at either the top or bottom of the window. The method is useful for immediately showing the user the result of some action without requiring the user to manually scroll through the document to find the result. This example underlines the content of the document's fifth paragraph and scrolls it into view at the top of the window.

var coll = document.all.tags ( "P" );
if ( coll.length >= 5 ) {
  coll ( 4 ).style.textDecoration = "underline";
  coll ( 4 ).scrollIntoView ( true );
  }


© 2025 Reynald Nuñez and asp.net.ph. All rights reserved.

If you have any question, comment or suggestion
about this site, please send us a note