我正在使用 WebBrowser 控件为 Windows 手机开发浏览器应用程序。我正在尝试使用以下代码实现自动滚动到底部。它工作正常,但是当页面document.body.scrollHeight
在条件检查中放大时
if (document.body.scrollHeight > (document.documentElement.scrollTop + window.innerHeight))
总是更大,导致函数被不间断地调用并且clearTimeout(timeOutDown)
永远不会到达终止。
var timeOutDown;
function scrollToBottom()
{
clearTimeout(timeOut);
if (document.body.scrollHeight > (document.documentElement.scrollTop + window.innerHeight))
{
window.scrollBy(0, 100);
window.external.notify(String(window.innerHeight));
timeOutDown=setTimeout('scrollToBottom()',10);
}
else
{
clearTimeout(timeOutDown);
}
}
考虑到用户可以放大/缩小页面,这样做的正确方法是什么?