Javascript

Scroll the page to element

Scroll the web window to a especific element of the dom document in a Javascript action. The code will refer the element by his id and push a margin to take better position.

code:

/* html file */

<div id="myid"></div>

/* js file */

document.getElementById("myid").scrollIntoView(); window.scrollBy(0, -20);