【发布时间】:2013-11-20 19:37:16
【问题描述】:
浏览器开发工具是一个很棒的工具。我想知道用户是否已从浏览器控制台到达页面末尾。当我尝试使用 javascript 执行此操作时,它显示“未定义”
我们应该如何处理 Ajax 加载的页面?如何判断用户是否已到达 AJAX 加载页面的末尾?
【问题讨论】:
-
请发布一个代码示例,说明您目前是如何执行此操作的。
标签: javascript google-chrome-devtools
浏览器开发工具是一个很棒的工具。我想知道用户是否已从浏览器控制台到达页面末尾。当我尝试使用 javascript 执行此操作时,它显示“未定义”
我们应该如何处理 Ajax 加载的页面?如何判断用户是否已到达 AJAX 加载页面的末尾?
【问题讨论】:
标签: javascript google-chrome-devtools
在您的控制台中尝试此代码:(来源:see the link)
setInterval(function(){
var totalHeight;
var currentScroll;
var visibleHeight;
if(document.documentElement.scrollTop){
currentScroll = document.documentElement.scrollTop;
}else{
currentScroll = document.body.scrollTop;
}
totalHeight = document.body.offsetHeight;
visibleHeight = document.documentElement.clientHeight;
if (totalHeight <= currentScroll + visibleHeight ){
console.log('bottom of page');
}
}, 1000);
【讨论】: