Window.scroll()

  • Revision slug: DOM/window.scroll
  • Revision title: window.scroll
  • Revision id: 173347
  • Created:
  • Creator: Dria
  • Is current revision? No
  • Comment

Revision Content

{{template.DomRef()}}

Summary

Scrolls the window to a particular place in the document.

Syntax

window.scroll(x-coord, y-coord) 

Parameters

  • x-coord is the pixel along the horizontal axis of the document that you want displayed in the upper left.
  • y-coord is the pixel along the vertical axis of the document that you want displayed in the upper left.

Example

 // put the 1000th vertical pixel at
 // the top of the window 
 <INPUT TYPE="button" VALUE="1000"
   onClick="scroll(0, 1000);"/>

Notes

window.scrollTo is effectively the same as this method. For scrolling a particular distance repeatedly, use the window.scrollBy. Also see window.scrollByLines, window.scrollByPages.

Specification

DOM Level 0. Not part of specification.

Revision Source

<p>
{{template.DomRef()}}
</p>
<h3 name="Summary">Summary</h3>
<p>Scrolls the window to a particular place in the document. 
</p>
<h3 name="Syntax">Syntax </h3>
<pre class="eval">window.scroll(<i>x-coord</i>, <i>y-coord</i>) 
</pre>
<h3 name="Parameters">Parameters </h3>
<ul><li><code>x-coord</code> is the pixel along the horizontal axis of the document that you want displayed in the upper left.
</li><li><code>y-coord</code> is the pixel along the vertical axis of the document that you want displayed in the upper left.
</li></ul>
<h3 name="Example">Example </h3>
<pre> // put the 1000th vertical pixel at
 // the top of the window 
 &lt;INPUT TYPE="button" VALUE="1000"
   onClick="scroll(0, 1000);"/&gt;
</pre>
<h3 name="Notes">Notes </h3>
<p><a href="en/Window.scrollTo">window.scrollTo</a> is effectively the same as this method. 
For scrolling a particular distance repeatedly, use the <a href="en/Window.scrollBy">window.scrollBy</a>. Also see <a href="en/Window.scrollByLines">window.scrollByLines</a>, <a href="en/Window.scrollByPages">window.scrollByPages</a>. 
</p>
<h3 name="Specification">Specification </h3>
<p>DOM Level 0. Not part of specification.
</p>
Revert to this revision