Javascript - Back To Top of Page II - Neils Resource WebJavascript - Back To Top of Page II - Neils Resource WebGo Top of Page - Javascript - WEB DEV. - NEILS RESOURCE WEB

Contract Menu | Expand Menu

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); 

Hyperlink titles may have been abbreviated, (right click on the link and select properties for the full URL)

Top of the PageTop of the PageA double mouse click anywhere on the page will take you back to the top (except when over hyperlinks)

Last Update: 04/03/2008 - Javascript - Back To Top of Page II - Neils Resource Web

html 4.01 strict css 2.1 javascript 1.2