How to hide anchor tag from URL

旧街凉风 提交于 2019-12-20 06:09:51

问题


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');">


来源:https://stackoverflow.com/questions/10045303/how-to-hide-anchor-tag-from-url

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!