1<style>
2 // NOTE: to auto scroll a div smoothly
3 #direct-chat-messages
4 {
5 scroll-behavior: smooth;
6 }
7</style>
8
9<script>
10// NOTE: to auto scroll a div.
11 window.setTimeout(function() {
12 var elem = document.getElementById('direct-chat-messages');
13 elem.scrollTop = elem.scrollHeight;
14 }, 100);
15</script>
1
2
3
4<style>
5
6 .scroll-text{
7 overflow-y: auto;
8 height: 61px;
9 width:auto;
10
11 }
12
13
14</style>
15
16
17 <div class="scroll-text" id="data">
18 f
19
20
21
22
23 </div>
24
25
26
27 <script>
28var my_time;
29var count = 0;
30setTimeout('pageScroll()', 1200);
31function pageScroll() {
32 if (count < 2) {
33 var objDiv = document.getElementById("data");
34 objDiv.scrollTop = objDiv.scrollTop + 1;
35 if (objDiv.scrollTop == objDiv.scrollHeight - 61) {
36 setTimeout(function () {
37 objDiv.scrollTop = 0;
38 count++;
39 }, 1200);
40 }
41 my_time = setTimeout('pageScroll()', 30);
42 }
43}
44 </script>
45