日期:2014-05-16 浏览次数:20542 次
<!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=utf-8" />
</head>
<body>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.min.js"></script>
<script type="text/javascript">
//怎么获取网页的高度 让页面一出来就滚动条在最底端
function myScroll() {
//前边是获取chrome等一般浏览器 如果获取不到就是ie了 就用ie的办法获取
var x=document.body.scrollTop||document.documentElement.scrollTop;
var timer=setInterval(function(){
x=x-100;
if(x<100) {
x=0;
window.scrollTo(x,x);
clearInterval(timer);
}
window.scrollTo(x,x);
},"200"); //200毫秒 控制滚动条的速度
}
</script>
<title></title>
</head>
<body id="bd">
<div>
<div style="height:1000px;">初始化</div>
<div style="height:1000px">
<div style="position:fixed;right:10px;bottom:50px;width:20px;height:70px;background-color:red;cursor:hand;"
onclick="myScroll()">返回顶端</div>
</div>
</body>
</html>