You are here: Reference > JavaScript > client-side > HTML DOM > methods > scrollByLines

scrollByLines method

Browser support:
Scrolls the contents of the document vertically by the specified number of lines.
This method performs the same action as when the down or up arrow of the vertical scrollbar is clicked.
In Internet Explorer, use the doScroll method to simulate a user action on a scroll-bar component.
The scrollByLines method is only supported by Firefox, use the cross-browser scrollBy method instead.

Syntax:

object.scrollByLines (numberOfLines);
You can find the related objects in the Supported by objects section below.

Parameters:

numberOfLines
Required. Integer that specifies the number of lines to scroll.

Return value:

This method has no return value.

Example HTML code 1:

This example shows how to scroll the document window by the specified number of lines:
<span>First line.</span>
<button onclick="window.scrollByLines (10);">Scroll the document vertically by 10 lines!</button>
<br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br />
<span>Second line.</span>
<button onclick="window.scrollByLines (10);">Scroll the document vertically by 10 lines!</button>
<br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br />
<span>Third line.</span>
<button onclick="window.scrollByLines (10);">Scroll the document vertically by 10 lines!</button>
<br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br />
<span>Fourth line.</span>
Did you find this example helpful? yes no

Supported by objects:

Related pages:

External links:

User Contributed Comments

Post Content

Post Content