Thread: Top of Page
View Single Post
Old 07-29-2003, 06:57 PM   PM User | #1
premshree
Regular Coder

 
Join Date: Jun 2002
Location: Mumbai, India
Posts: 218
Thanks: 0
Thanked 0 Times in 0 Posts
premshree is an unknown quantity at this point
Top of Page

Use this JavaScript to add a "Top of Page" link at the bottom of your page.

The link will be displayed only if the contents of the page exceeds the size of the browser window, i.e. if the scrollbars appear.

Code:
<script language="JavaScript">
/* Place this script at the bottom of your page */

//////////////////////////////////////////
//	Top of Page JavaScript		//
//	By Premshree Pillai		//
//	http://www.qiksearch.com	//
//////////////////////////////////////////

/* Message to be displayed */
var topOfPageMsg='<a href="#" class="top">Top of Page</a>';

var ie4=document.all&&navigator.userAgent.indexOf("Opera")==-1;
var ns6=document.getElementById&&navigator.userAgent.indexOf("Opera")==-1;
var ns4=document.layers;
lC=(ie4)? document.body.scrollHeight : document.height;
rC=(ie4)? document.body.clientHeight : window.innerHeight-20;
if(lC>rC) {
	document.write(topOfPageMsg);
}
var agt=navigator.userAgent.toLowerCase();
function nsReload() { window.location.reload(); }
function reLoad() {
	if (ns4&&(agt.indexOf("win")!=-1)) {
		setTimeout("window.onresize=nsReload", 500);
	}
}
if(ns4) {
	reLoad();
}
else if(ie4) {
	window.onresize=new Function("window.location.reload()");
}
</script>
See example here: http://www.premshree.resource-locato...op-of-page.htm


Last edited by premshree; 07-29-2003 at 06:59 PM..
premshree is offline   Reply With Quote