Javascript 'redirect' without page reload
This question has been asked before but I need a more cross-browser* option not the git-hub one.
Is there anyway to change :
http://stackoverflow.com/test#hey
to :
http://stackoverflow.com/test
开发者_Python百科using javascript without reloading the page ? (hitting the server again)
*by 'more cross-browser' I mean IE7+ FF3.5+, not IE6, etc
You could use history.pushState()
for this.
This will remove the hash:
history.replaceState( {}, '', location.href.split('#')[0] );
For cross-browser compatibility, you could use history.js as a polyfill.
精彩评论