不工作这是我在我的JS JS文件滚动顶值=滚动身高在Chrome
function refreshChat()
{
//speed up by selecting the div only once
var shoutbox = $("#shoutbox");
//get the height of the scroll (if any)
var oldScrollH = shoutbox.attr("scrollHeight") - 20;
//the ajax request
$.ajax({
url: 'shoutbox/update.php',
//disable cache
cache: false,
success: function(html) {
//update the shoutbox
shoutbox.html(html);
//get the heigth of the scroll after the update
var newScrollH = shoutbox.attr("scrollHeight") - 20;
if(newScrollH > oldScrollH)
{
//*move* the scroll down using an animation :)
shoutbox.animate({scrollTop: newScrollH}, 1);
}
}
});
}
//set the refreshChat function to run every *refreshSeconds*
setInterval(refreshChat, refreshSeconds);
});
它工作在Firefox和IE的罚款,但与谷歌浏览它不断的笔触。它会在页面加载时滚动到底部,但是当它调用功能refreshChat
时,它会在div的一半左右移回。
我也有这个在我<head>
$(document).ready(function(){
//speed up by selecting the div only once
var shoutbox = $("#shoutbox");
//get the height of the scroll (if any)
var oldScrollH = shoutbox.attr("scrollHeight");
//the ajax request
$.ajax({
url: 'shoutbox/update.php',
//disable cache
cache: false,
success: function(html) {
//update the shoutbox
shoutbox.html(html);
//get the heigth of the scroll after the update
var newScrollH = shoutbox.attr("scrollHeight");
if(newScrollH > oldScrollH)
{
//*move* the scroll down using an animation :)
shoutbox.animate({scrollTop: newScrollH}, 1);
}
}
})
});
,这样它会自动加载上留言在页面加载,这可能与它有冲突?这似乎是合乎逻辑的,但我不希望用户必须等待3秒才能将最大加载速度提高。
你可以在jsfiddle.net上展示你的问题吗? –
@ExplosionPills我真的不知道如何,吼吼箱是PHP编码,所以我不知道我会怎么去做,因为我从来没有用过jsfiddle。 – kira423
您是否在Chrome开发者工具中遇到任何错误? –