2

チャット ボックスの自動スクロールが停止しません (上にスクロールできません)。どこに問題があるかはわかっていますが、回避方法がわかりません。自動スクロールするにはチャットボックスが必要ですが、同時に上にスクロールできるようにしたいです。

これが問題の実際のです。

//Load the file containing the chat log
function loadLog(){     
    $("#chatbox").animate({ scrollTop: 99999 }, 'normal');
    $.ajax({
        url: "log.html",
        cache: false,
        success: function(html){        $("#chatbox").animate({ scrollTop: 99999 }, 'normal');
        $("#chatbox").html(html);
        $("#chatbox").animate({ scrollTop: 99999 }, 'normal');



        }               

    });
}
4

1 に答える 1

1

スコール位置がいつなのかを確認できます。それが一番下の場合は、一番下までスクロールします

//Load the file containing the chat log
function loadLog(){     
  // remove  $("#chatbox").animate({ scrollTop: 99999 }, 'normal');
    $.ajax({
        url: "log.html",
        cache: false,
        success: function(html){     
        var chatbox= $("#chatbox");
        var atBottom = (chatbox[0].scrollHeight - chatbox.scrollTop() == chatbox.outerHeight());
        chatbox.html(html);

        if (atBottom )
         chatbox.animate({ scrollTop: 99999 }, 'normal');



        }               

    });
}
于 2012-09-19T04:18:11.290 に答える