Reputation: 960
Recently, our family has started watching HGTV-style shows on Netflix. One of our favorites is the Property Brothers. I went Googling today and visited this link:
I went scrolling down the page, and was surprised to see the URL in the URL bar change as I went onto the next article. The previous article was still above, and the URL switched back when I scrolled back up. How does Today.com switch URLs without loading a new page like this? It's seamless!
I have heard of the History API before in relation to Facebook. Is this what's being used?
Upvotes: 1
Views: 36
Reputation: 183436
I have heard of the History API before in relation to Facebook. Is this what's being used?
Yes. From MDN's "Manipulating the browser history" web-guide:
Suppose http://mozilla.org/foo.html executes the following JavaScript:
var stateObj = { foo: "bar" }; history.pushState(stateObj, "page 2", "bar.html");
This will cause the URL bar to display http://mozilla.org/bar.html, but won't cause the browser to load
bar.html
or even check thatbar.html
exists.
(See the above-linked guide for much more information.)
Upvotes: 1