How to hide anchor tag from URL

2019-03-03 18:14发布

问题:

How can I hide the hash value from the following link href in the address bar?

<a href="index.php#dev_name">

So it'll redirect me to a the index.php#dev_name, but I want the address bar to only show index.php

回答1:

You can use a Javascript onclick event. The browser will still show index.php, but the onclick event will trigger first, and redirect the browser to the right page.

<a href="index.php" onclick="location.redirect('index.php#dev');">