Question

Simply put: I have a single-page website, for instance www.example.com. How do I make a link pointing to www.example.com/sub not trigger an unload, but still change the address bar as if it did?

example1

example2

Was it helpful?

Solution

HTML History API can do this.

history.pushState({data: "foo"}, "SubPage", "http://www.example.com/sub")

You can kind-of use History JS to shim it in for the older browsers (it will fake it with hash links in non-compliant browsers).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top