向上滚为负,下为正.
<!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>
<!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>
解决方案 »
- 求指点:怎么作出这个效果,让网页加载完一段再显示一段,然后再加载再显示。
- JS 取得时间段内的自然周
- 求JavaScript视频教程
- 关于js的模态对话框问题
- 大连的朋友帮帮俺喽
- <a href="JavaScript:window.external.AddFavorite('http://127.0.0.1','Page')"><font color="white">添加到收藏夹</FONT></a>有什么错?
- 调用js文件出错!
- 这种效果的代码是用js吗
- 如何判断读的文本文件已经结束?
- 使用JS调用高德地图API获取行政区资料时检索正常和key都正常缺获取不到数据
- 有什么办法把复选框变灰色(不可选)
- 怎么才能让JS中做一个停止10秒的动作后,再执行下面的语句,类似API函数中SLEEP的功能???高手进
//<![CDATA[
var x=a=0;
function foo(){
x==document.body.scrollTop?"":new function(){a=document.body.scrollTop-x;x=document.body.scrollTop;}
var o=document.getElementById("demo");
o.style.top=document.body.scrollTop; o.innerHTML=a;
}
//]]>
</script>
<body id="www.never-online.net" onscroll="foo()">
<div id="demo" style="position:absolute"></div>
<div style="height:2400"></div>
</body>