Click to Rate and Give Feedback
MSDN
MSDN Library
Web Development
HTML and CSS
Methods
 scrollIntoView Method
scrollIntoView Method

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

Syntax

object.scrollIntoView( [bAlignToTop])

Parameters

bAlignToTop Optional. Boolean that specifies one of the following values:
true
Default. Scrolls the object so that top of the object is visible at the top of the window.
false
Scrolls the object so that the bottom of the object is visible at the bottom of the window.

Return Value

No return value.

Remarks

The scrollIntoView 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.

Depending on the size of the given object and the current window, this method might not be able to put the item at the very top or very bottom, but will position the object as close to the requested position as possible.

Example

This example uses the scrollIntoView method to underline the content of the document's fifth paragraph and scroll 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);
   }

Standards Information

There is no public standard that applies to this method.

Applies To

A, ADDRESS, APPLET, AREA, B, BIG, BLOCKQUOTE, BR, BUTTON, CAPTION, CENTER, CITE, CODE, COL, COLGROUP, COMMENT, controlRange, CUSTOM, DD, DFN, DIR, DIV, DL, DT, EM, EMBED, FIELDSET, FONT, FORM, hn, HR, I, IFRAME, IMG, INPUT type=button, INPUT type=checkbox, INPUT type=file, INPUT type=image, INPUT type=password, INPUT type=radio, INPUT type=reset, INPUT type=submit, INPUT type=text, KBD, LABEL, LEGEND, LI, LISTING, MAP, MARQUEE, MENU, NOBR, OBJECT, OL, P, PLAINTEXT, PRE, S, SAMP, SELECT, SMALL, SPAN, STRIKE, STRONG, SUB, SUP, TABLE, TBODY, TD, TEXTAREA, TextRange, TFOOT, TH, THEAD, TR, TT, U, UL, VAR, WBR, XMP, ControlRangeCollection Constructor, Element Constructor, TextRange Constructor
Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
automation anomaly - browser version      Mr. Raymond Kenneth Petry   |   Edit   |   Show History

MSIE 7 automatically fires scrollIntoView after a move scrollTop by Script, ('pops-back' the last selection; eg. using the rovot right-button to yank the document; But note also that right-button can be scripted to Click-select, But-then right-button onmouseup may-be suppressed).

MSIE 6 did not-automatically
, until cursor was key-moved or selected, (MSIE 7 does also).

Nevertheless MSIE on-nudge resumes the rovot new right-button-selection-scroll-position;

(In summary, MSIE 7 is comparatively defective: for not staying-put onmouse[right]up,- unless you mouse-off the element: then, it stays-put ... but still-again you can left-click).

[This is one of those features where we'd like "auto" and "center" to scroll-only-if-necessary...]

IE8 bug?      BJSChi   |   Edit   |   Show History
scrollIntoView does not seem to work when IE8 is in standards mode.
Tags What's this?: Add a tag
Flag as ContentBug
Processing
© 2010 Microsoft Corporation. All rights reserved. Terms of Use | Trademarks | Privacy Statement
Page view tracker