<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<HEAD>
<TITLE>随滚动条移动层</TITLE>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html" charset="gb2312">
</HEAD>
<style>
<!--
#up_down_div{
position: absolute;
border: 1px solid gray;
background-color: #e3eff3;
width: 50px;
height:23px;
}
-->
</style>
<SCRIPT LANGUAGE="JavaScript">
function G(va) {
return document.getElementById(va);
}
function changeT() {
if(G("btn_up").value == "顶端") {
javascript:scroll(0,0);
G("btn_up").value="底端";
} else if(G("btn_up").value == "底端") {
javascript:scroll(0,document.body.scrollHeight);
G("btn_up").value="顶端";
} else {
window.location.reload();
}
}
function sc(){
G("up_down_div").style.top=(document.documentElement.scrollTop+(document.documentElement.clientHeight-G("up_down_div").offsetHeight)/2)+"px";
G("up_down_div").style.left=(document.documentElement.scrollLeft+document.documentElement.clientWidth-G("up_down_div").offsetWidth)+"px";
}
function scall(){
sc();
}
window.οnscrοll=scall;
window.οnresize=scall;
window.οnlοad=scall;
</SCRIPT>
<BODY>
<div >我是MVP</div>
<table style="width: 600;height:1000;" border="1"></table> <!-- 这里不一定是用table,长度、宽度自己设置 -->
<div id="up_down_div" align="center"><input id="btn_up" type="button" value="顶端" οnclick="changeT()"/></div>
<div>你是什么</div>
</BODY>
</HTML>