向下滚动具有更改URL的页面

Scroll-down page with changing URL

本文关键字:URL 滚动      更新时间:2023-09-26

我注意到这个科普页面在向下滚动时动态加载内容:http://www.popsci.com/HTC-Oculus-Competitor-Valve-Vive

他们是怎么做到的?好的,当用户滚动到某个点时,在页面底部加载额外的内容并不难。但是这个页面更改了页面的URL,并且没有可见的页面重新加载/刷新。

他们正在使用HTML5历史API来实现这一点。主要是history对象的pushStatepopStatereplaceState功能。

Mark Pilgrim在他的网站上为历史API写了一篇非常好的介绍:http://diveintohtml5.info/history.html.

参考:https://developer.mozilla.org/en-US/docs/Web/Guide/API/DOM/Manipulating_the_browser_history