快速返回到TOP
作者:cmscn 日期:2007-04-14
引用内容
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>runcode</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="Author" content="Sheneyan" />
<script>
function s2top(){
var a = document.getElementsByTagName('a');
var l = a.length;
for (var i = 0 ; i < l ; i ++){
var ai = a[i];
if (/#header$/.test(ai.href)){
ai.onclick = function(){
var o = this;
var ot = o.offsetTop;
for (var t = 0 ; t < 20 ; t ++){
setTimeout("scrollBy(0,-" + parseInt(ot / 20) + ")",t * 50 + 1);
}
return false;
}
}
}
}
</script>
<body onload="s2top()">
</body>
<p>
<script>
for (var i = 0 ; i < 1000 ; i ++)
document.write(i+"<br>");
</script>
</p>
<a href="#header">go to 头</a>
</body>
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>runcode</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="Author" content="Sheneyan" />
<script>
function s2top(){
var a = document.getElementsByTagName('a');
var l = a.length;
for (var i = 0 ; i < l ; i ++){
var ai = a[i];
if (/#header$/.test(ai.href)){
ai.onclick = function(){
var o = this;
var ot = o.offsetTop;
for (var t = 0 ; t < 20 ; t ++){
setTimeout("scrollBy(0,-" + parseInt(ot / 20) + ")",t * 50 + 1);
}
return false;
}
}
}
}
</script>
<body onload="s2top()">
</body>
<p>
<script>
for (var i = 0 ; i < 1000 ; i ++)
document.write(i+"<br>");
</script>
</p>
<a href="#header">go to 头</a>
</body>
评论: 7 | 引用: 0 | 查看次数: 670
发表评论