开发者

Javascript 'redirect' without page reload

开发者 https://www.devze.com 2023-02-27 15:19 出处:网络
This question has been asked before but I need a more cross-browser* option not the git-hub one. Is there anyway to change :

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消