右下角随滚动条自动滚动的javascript实现代码
<!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" />
<title>右下角随滚动条自动滚动的javascript实现代码</title>
<style>
html,body{
height:2000px;
}
</style>
</head>
<body>
<div id="aa" style="width:200px;height:200px;background:#c0c0c0;" >我在随平滚</div>
</body>
</html>
<script>
-function(p){
var d = document,w = window,o = d.getElementById(p.id);
if(o){
o.style.cssText +=";position:absolute;"+(p.r?'left':"right")+":0;";
(function(){
var t = 500,st = d.documentElement.scrollTop||d.body.scrollTop,c;
c = st - o.offsetTop + (p.t||(w.innerHeight||d.documentElement.clientHeight)-o.offsetHeight);//如果你是html 4.01请改成d.body,这里不处理以减少代码
c!=0&&(o.style.top = o.offsetTop + Math.ceil(c/10) + 'px',t=10);
setTimeout(arguments.callee,t)
})()
}
}({
id:'aa'
})
/*
id 你要滚动的内容的id
r 放在左边还是右边 默认是右边
t 你要放在页面的那个位置默认是贴着边
*/
</script>

