向上滚为负,下为正.
<!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>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
</head><body>
<div style="height:2000px;"></div>
<div id="label" style="position:absolute;"></div>
<script>
var Top=document.documentElement.scrollTop;
label.style.pixelLeft=500;
/*
window.onscroll=function(){
refreshlabel();
}
*/
// OR
setInterval("refreshlabel()",1000)
function refreshlabel(){
if(document.documentElement.scrollTop!=Top){
label.innerText=document.documentElement.scrollTop-Top;
label.style.pixelTop=document.documentElement.scrollTop+100;
Top=document.documentElement.scrollTop;
}
}
</script>
</body>
</html>