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 >>
<!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;
width:400px;
border:solid 1px #ccc;
}
</style>
<body>
<div class="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>