[英]Implement links on single-page web design
Simply put: I have a single-page website, for instance www.example.com. 简而言之:我有一个单页网站,例如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?
如何使指向www.example.com/sub的链接不会触发卸载, 但仍然像更改地址栏一样触发它?
HTML History API can do this. HTML History API可以做到这一点。
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). 您可以使用History JS对较旧的浏览器进行填充(它会在不兼容的浏览器中使用哈希链接来伪造它)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.