javascript - 当用户单击该链接时,如何避免在地址栏中显示 id?

标签 javascript html css

我在 <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/

相关文章:

javascript - Firefox OS 特权应用程序上的 Flurry 分析

javascript - 在 html div 中显示 javascript 变量

jquery - 下拉菜单隐藏在 Bootstrap 模态中

php - 如何使用 TCPDF 库在 PDF 中制作 Angular 带

javascript - 箭头表示法在 Internet Explorer 中不适用于 data.reduce

javascript - 使用javascript动态编辑多个相同的HTML表单

javascript - 时间复杂度 : 3Sum algorithm under cubic time?

javascript - 如何使用onmouseover?

html - 使用仅使用 CSS 的外部 div 标签修改 2 x 内部 div 标签

html - 在IE7中定位消息(CSS)