문제

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

도움이 되었습니까?

해결책

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).

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top