JAVASCRIPT DIV 스크롤 및 하단으로 이동

예제 1 =====================================
<style type="text/css">
<!--
div.scroll {
height: 220px;
width: 97%;
overflow: auto;
padding: 8px;
}
-->
</style>

<div class="scroll">
<span id='order_list'>
111<br>
1112<br>
21212<br>
1212121<br>
121212121<br>
asfas<br>
asdfasdfasfasf<br>
sfasdfas<br>
asfasf<br>
asdfasdfas<br>
fasdfas<br>
fasdfas<br>
fasdfasfasfa<br>
asfdasf<br>
asf<br>
asfasfasfasf
</span>
<a name='test'>&nbsp;</a>
</div>

<script>
function test()
{
location.hash='test';
}
</script>
<input type=button value='test' onclick=test()>

예제 2 ============================================

<style>
.cbody {
overflow: auto;
position: absolute;
font-family: "굴림", "돋움";
font-size: 12px;
line-height: 150%;
text-decoration: none;
background-color: #FFFFFF;
left: 10px;
top: 0px;
height: 100px;
width: 500px;
}
</style>

<div id="chatbody" name='chatbody' class="cbody">
1<br>
1<br>
1<br>
1<br>
1<br>
1<br>
1<br>
1<br>
1<br>
1<br>
1<br>
</div>

<script langage="JavaScript">
test_id = document.getElementById("chatbody");
test_id.scrollTop = test_id.scrollHeight;
</script>

답글 남기기

이메일 주소는 공개되지 않습니다. 필수 필드는 *로 표시됩니다