仅作为起点
检测您何时位于页面底部可以使用 jQuery 使用此代码完成。
$(window).scroll(function(){
if ($(window).scrollTop() == $(document).height()-$(window).height()){
alert("We're at the bottom of the page!!");
}
});
附加到正文的末尾可以通过ajax调用来完成
$(window).scroll(function(){
if ($(window).scrollTop() == $(document).height()-$(window).height()){
$.ajax({
url: "your.html",
success: function (data) { $('body').append(data); },
dataType: 'html'
});
}
});
我不确定您打算如何获取无限量的数据?
来自 cmets 的第 2 部分
如果不更改谷歌浏览器本身,Chrome 不允许本地 ajax 请求。
在本地机器上最容易启动的 Web 服务器是 php Web 服务。下载 PHP 并创建 php.exe 的快捷方式,快捷方式的目标是
C:\PHP\php.exe -S Localhost:80
目录中的开始将是 html 的位置。 index.html 或 index.php 需要在目录的开头,http:// ... localhost 将拉起 index.php 或 index.html。我将开头留空,并将快捷方式复制到我想用作当前开发工作的本地主机的文件夹中。
PHP可以从http://php.net/下载
网络服务器的手册在这里http://www.php.net/manual/en/features.commandline.webserver.php
没有 Ajax
没有无限数据(ajax 到 PHP 调用)更容易,也不需要 jquery。 iframe 可以附加到页面的末尾,而不需要本地服务器。
<div style="height:125%">
<h1>Chapter 1</h1>
</div>
<script>
var page=1;
window.onscroll = function(ev) {
if ((window.innerHeight + window.scrollY) >= document.body.offsetHeight) {
ifrm = document.createElement("IFRAME");
ifrm.setAttribute("src", page+".html");
ifrm.style.width = 100+"%";
ifrm.style.height = 800+"px";
document.body.appendChild(ifrm);
page++
}
};
</script>