1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
| function load_online(){
var oldscrollHeight = $("#online").attr("scrollHeight") - 20;
$.ajax({
url: "online_tchat.php",
cache: false,
success: function(html){
$("#online").html(html);
//Auto-scroll
var newscrollHeight = $("#online").attr("scrollHeight") - 20; // ScrollHeight après la demande
if(newscrollHeight > oldscrollHeight){
$("#online").animate({ scrollTop: newscrollHeight }, 'normal'); // Défilement automatique en bas de div
}
},
});
}
setInterval (load_online, 2500); |
Partager