我正在尝试获取每 2 秒刷新一次的 div,以在 2 秒刷新后停止滚动回顶部我有 PHP 代码和 javascript。我使用的 Javascript 是:
function at_Ticket_scrollBottom()
{
var objDiv = document.getElementById("cartTicket");
objDiv.scrollTop = objDiv.scrollHeight;
}
function at_Tabs_Update()
{
if(div_WPOSVar_IsVisible())
{
//calling setTimeout without clearing any existing timeout can add multiple calls.
//IE the normal 2 second sequence, then call at_Tabs_Update two more times, and
// now we have 3 timeouts set to call at_Tabs again, etc.
//This wouldn't be an issue except that we call at_Tabs_Update directly to cause
// immediate refresh from many places.
//So clear the handle everytime to get rid of the last one we set.
clearTimeout(at_Tabs_Timer);
at_Tabs_Timer=setTimeout("at_Tabs_Update()", 2*1000); //every 2 seconds
return;
}
}
因此,刷新后,如果我向下滚动到票证的底部,它会在下一次刷新后跳回顶部,所以我永远无法到达底部并选择一个项目并在刷新之前对其进行编辑如何停止自动回滚到顶部。