[英]Why are all links opening in new tab with bootstrap?
I'm using bootstrap on a page with a navbar.我在带有导航栏的页面上使用引导程序。 I'm currently experiencing two problems that I believe are related.
我目前遇到两个我认为相关的问题。
1) All navbar links are opening a new tab. 1) 所有导航栏链接都将打开一个新选项卡。
2) Collapsible elements, rather than collapsing or expanding when clicked are also opening a new tab. 2) 可折叠元素,而不是在点击时折叠或展开也会打开一个新选项卡。 For instance, using example code, clicking on a collapsing element that involves this piece of code:
例如,使用示例代码,单击涉及这段代码的折叠元素:
<a data-toggle="collapse" data-parent="#accordion" href="#collapse1">
Actually opens a new tab at http://domain/#collapse1实际上在http://domain/#collapse1打开一个新标签
I believe these two problems are related.我相信这两个问题是相关的。
From my <head>
从我的
<head>
<!-- Bootstrap -->
<link href="http://.../include/bootstrap/css/bootstrap.min.css" rel="stylesheet">
<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
<script src="http://.../include/bootstrap/bootstrap.js"></script>
But even when I load the css and js from bootstraps site, I get the same results.但即使我从引导站点加载 css 和 js,我也得到相同的结果。
An example of the navbar code:导航栏代码示例:
<nav class="navbar navbar-fixed-top navbar-default" role="navigation">
<div class="navbar-header">
<ul class="nav navbar-nav">
<li class="nav-item">
<a class="nav-link" href="http://.../">home</a>
</li>
<li class="nav-item">
<a class="nav-link" href="http://.../portfolio/">Portfolio</a>
</li>
<li class="nav-item active">
<a class="nav-link" href="http://.../cv/">CV<span class="sr-only">(current)</span></a>
</li>
<li class="nav-item">
<a class="nav-link" href="http://.../contact/">Contact</a>
</li>
</ul>
</div>
</nav>
And yet, all of these open in new tabs.然而,所有这些都在新标签中打开。 Any ideas?
有什么想法吗?
I had the same issue.我有同样的问题。 I fixed it by adding the following:
我通过添加以下内容修复了它:
Original Link:原文链接:
<a class="nav-link" href="http:...">Home</a>
New Link:新链接:
<a class="nav-link" target="_self" href="http:...">Home</a>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.