Go Top of Page - Javascript - WEB DEV. - NEILS RESOURCE WEB |
Summary of Content |
This javascript is the simplest solution for long pages. By default a double mouse click anywhere on a page (except when over hyperlinks) will return you to the top of the page. You can, in fact, by chaging the co-ordinates jump to any physical location on a page. Unlike a bookmark which needs a link from a specific location, this will work anywhere. It features on every page of this site. |
A double mouse click anywhere on the page (except when over hyperlinks) will take you back to the top. |
The script (in the Head section) |
<script language="JavaScript1.2"> <!-- function dblclick() { window.scrollTo(0,0) } if (document.layers) { document.captureEvents(Event.ondblclick); } document.ondblclick=dblclick; //--> </script> |
window.scrollTo() |
Scrolls to a particular set of coordinates in the document.
Syntax window.scrollTo() 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 window.scrollTo(0, 0); |