Causes the object to scroll into view, aligning it either at the top or bottom of the window.
Syntax
object.scrollIntoView(varargStart)Standards information
There are no standards that apply here.
Parameters
- varargStart [in, optional]
-
Type: VARIANT
Variant of type Boolean that specifies one of the following values:
Return value
Type: HRESULT
If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.
Type: HRESULT
If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.
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.
Examples
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);
}
Send comments about this topic to Microsoft
Build date: 2/14/2012
I'm using Internet Explorer
Version8.0.6001.18702
Compatibility View
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
Surprisingly, if invoked twice in succession for the same object, the 2nd invocation also scrolls the object to the left so that what used to be past the right side of the screen now comes into view. In my case I can now see the entire width of my DIV object.
I click a button mapped to myDivObj.scrollIntoView(true) twice to achieve this.
(REMEDY: See also-- componentFromPoint(), scrollTop, clientTop. offsetTop.)
2.Lacks 'non-greedy' parameter to just-scoot the object into view, (It goes for the object-extremity).
3. This feature involves the window: At the extremity of object-scrolling it'll yank the document if it can.
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...]