简体   繁体   中英

How to remove anchor (#hash) from url after clicking a bookmark link

on the site example.html i have the link href="index.html#section1 ".
when you click the link, the url is index.html#section1, but is there a way to only display index.html but still go to the Id #section1 ?

I found this: Removing anchor (#hash) from URL but i don't know how to use it since i only understand a little javascript. maybe someone can help out with a detailed instruction where to insert which code.

You can't change the data after the hash without re-directing the page but you can re-name it with

location.hash = "new-location"

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