简体   繁体   中英

Remove the hash symbol from URL

how can I remove the hash symbol in a url?

I have www.foobar.com/#test I want now www.foobar.com/test .

Is this a stupid idea or have it now bad results?

Cheers

You could use pushState() like this :

window.history.pushState(null, "", window.location.href.replace("#", "")) ;

This will remove the hash, without reloading the page.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM