我又一次对JS感到沮丧了!请帮帮我!
以下是我用于简单聊天应用程序的一些代码,通过AJAX请求从文本文件刷新内容。同时,它会滚动到窗口底部。我希望如果用户向上滚动以跟上进度,则不会在刷新时打断这种行为,而是继续保持他们的位置。我该如何做?
<script>
$(function() {
startRefresh();
});
function startRefresh() {
setTimeout(startRefresh,3000);
$.post('pollchat.php', function(data) {
$('#content_div_id').html(data);
var wtf = $('#content_div_id');
var height = wtf[0].scrollHeight;
wtf.scrollTop(height);
});
}
</script>
Any help greatly appreciated.