function ScrollDiv() {
var ex = document.getElementById("calm");
ex.scrollTop = ex.scrollHeight;
}
obj.scrollTop:滚动条距离顶部的位置
obj.scrollHeight:流动区域的高度
<HEAD>
<TITLE>测试表格内的滚动条</TITLE>
</HEAD>
<BODY>
<table>
<tr>
<td>表格内的滚动条:</td>
<td>
<div id="wins"
style="position:absolute;height:200;200;overflow:auto;background:#EEEEEE;">
<p>pppppppppppppppppppppppppppppppppppppppppppppppppp </p>
<p>pppppppppppppppppppppppppppppppppppppppppppppppppp </p>
<p>ppppppppppppppppppppppppp </p>
<p>ppppppppppppppppppppppppp </p>
<p>ppppppppppppppppppppppppp </p>
<p>ppppppppppppppppppppppppp </p>
<p>ppppppppppppppppppppppppp </p>
<p>ppppppppppppppppppppppppp </p>
<p>ppppppppppppppppppppppppp </p>
<p>ppppppppppppppppppppppppp </p>
<p>ppppppppppppppppppppppppp </p>
<p>ppppppppppppppppppppppppp </p>
</div>
</td>
</tr>
<tr>
<td colspan="2" align="right">
<span onmouseover='scrollb=setInterval("wins.scrollLeft-=10",100)'
onmouseout=clearInterval(scrollb)>向左</span>
<span onmouseover='scrollb=setInterval("wins.scrollTop-=10",100)'
onmouseout=clearInterval(scrollb)>向上</span>
<span onmouseover='scrollb=setInterval("wins.scrollLeft+=10",100)'
onmouseout=clearInterval(scrollb)>向右</span>
<span onmouseover='scrollb=setInterval("wins.scrollTop+=10",100)'
onmouseout=clearInterval(scrollb)>向下</span>
</td>
</tr>
</table>
</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=utf-8" />
<title>JS控制DIV滚动条</title>
</head>
<script>
function scrollup()
{
document.getElementById('div1').scrollTop = document.getElementById('div1').scrollTop-25;
}
function scrolldown()
{
document.getElementById('div1').scrollTop = document.getElementById('div1').scrollTop+25;
}
function scrolltop()
{
document.getElementById('div1').scrollTop = 0;
}
function scrollbottom()
{
document.getElementById('div1').scrollTop = document.getElementById('div1').scrollHeight;
}
</script>
<style>
.div1
{
height:200px;
overflow-y:scroll;
400px;
border:solid 1px #ccc;
}
</style>
<body>
<div class="div1" id="div1"><br />
start<br />
<br /><br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
middle<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
end<br />
</div>
<input name="" type="button" value="向上"/ onclick="scrollup();">
<input name="" type="button" value="向下" onclick="scrolldown();"/>
<input name="" type="button" value="顶"/ onclick="scrolltop();">
<input name="" type="button" value="底" onclick="scrollbottom();"/>
</body>
</html>