我在 <li>
中有一个 anchor 标签像这样标记
<li><a href="#fragment-1">Primary Details</a></li>
但问题是我希望链接显示 ID 为 fragment-1 的 div。但点击链接后,div id 会显示在如下 url 中
http://localhost:90/index.php#fragment-1
如何阻止 div id 与 url 一起显示??
最佳答案
你能试试这个吗
<script language="javascript" type="text/javascript">
function redirect(URL)
{
document.location=URL;
return false;
}
</script>
<a href="#fragment-1" onclick="return redirect('http://localhost:90/index.php');">Click here</a>
关于javascript - 当用户单击该链接时,如何避免在地址栏中显示 id?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8686759/