Dynamic URL change without page reload
Is there a way to change URL of a website without reloading page? (Without "#" or Javascript.popState()
event开发者_运维百科 ).
For example : if I click a button change URL from /
to /new_url
with no page reload.
If is it possible, I'd like to use pure JavaScript, and I need cross browser support.
I think the answer is: No
You will need to use the URL hash. They were created just to do that.
In JavaScript, the fragment identifier of the current HTML or XHTML page can be accessed in the "hash" property location.hash — note that Javascript can be also used with other document types. With the rise of AJAX, some websites use fragment identifiers to emulate the back button behavior of browsers for page changes that do not require a reload, or to emulate subpages.
Wikipedia
Still, I don't get it. What is your problem with hashes anyway?
This is possible using pushState, although cross browser support is limited (but you can fall back to reloading the page).
精彩评论