JavaScript Reference/Javascript Methods/scrollIntoView
"scrollIntoView()" Example
<html>
<body>
<script language="JavaScript">
function function1(){
document.all.myDiv.scrollIntoView(true);
}
function function2(){
window.scrollTo(0,0);
}
</script>
<input type="button" value=" Scroll to the myDiv" onClick="function1();">
<div style="height:1000;background-color:blue;"></div>
<div id=myDiv onclick="function2();">
This is the element scrolled into view. Click here to go to top.
</div>
</body>
</html>
"scrollIntoView()" is applied to
Names noted with an asterisk (*) are JavaScript properties only.
+----------------+--------------------------------------------------------------+
| Applied_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> |
+----------------+--------------------------------------------------------------+
"scrollIntoView()" Syntax, Parameters and Note
Note:
Scrolls the window until the element is visible.
Syntax:
document.all.elementID.scrollIntoView(param1)
Parameters:
param1 Optional; true or false, indicating whether the top of the element
is scrolled to the top of the window or the bottom of the
element is scrolled to the bottom of the window.