Austin Burk
Austin Burk

Reputation: 960

How does today.com switch URLs like this?

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:

http://www.today.com/home/property-brothers-give-peek-inside-their-beautifully-renovated-las-vegas-1D80297959 (wow)

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

Answers (1)

ruakh
ruakh

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 that bar.html exists.

(See the above-linked guide for much more information.)

Upvotes: 1

Related Questions