如何修复导航栏链接打开新窗口

时间:2019-05-17 14:25:00

标签: nav

我最近使用引导程序创建了一个新的导航栏。请注意,我非常新-引导的新手。单击导航栏中的链接时,这些链接会打开一个新窗口。我希望链接在同一窗口中打开。

我在某处读到它可能是单个计算机的设置,并在控制面板中更改了设置,以确保将其选中为“在当前窗口中打开”,但这似乎不起作用。我也尝试在链接中添加target = _“ self”,但这似乎完全破坏了链接。

<!DOCTYPE html>
<html lang="en">
<head>
  <title>Company Page Demo</title>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/css/bootstrap.min.css">
  <link href="https://fonts.googleapis.com/css?family=Montserrat" rel="stylesheet" type="text/css">
  <link href="https://fonts.googleapis.com/css?family=Lato" rel="stylesheet" type="text/css">
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.0/jquery.min.js"></script>
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/js/bootstrap.min.js"></script>
  <style>

  .container-fluid {
    padding: 60px 50px;
  }

  .carousel-control.right, .carousel-control.left {
    background-image: none;
    color: #d3d3d3a4;
  }
  .carousel-indicators li {
    border-color: #006272;
    text-align: right;
    float: center;
    right: 2% !important;
    left: inherit;;
  }
  .carousel-indicators li.active {
    background-color: #d3d3d3a4;
  }

  .navbar {
    margin-bottom: 0;
    background-color: #006272;
    z-index: 9999;
    border: 0;
    font-size: 12px !important;
    line-height: 1.42857143 !important;
    letter-spacing: 2px;
    border-radius: 0;
    font-family: Montserrat, sans-serif;
  }
  .navbar li a, .navbar .navbar-brand {
    color: #fff !important;
  }
  .navbar-nav li a:hover, .navbar-nav li.active a {
    color: #006272 !important;
    background-color: #fff !important;
  }
  .navbar-default .navbar-toggle {
    border-color: transparent;
    color: #fff !important;
  }

  </style>
</head>
<body id="myPage" data-spy="scroll" data-target=".navbar" data-offset="60">

<nav class="navbar navbar-default navbar-fixed-top">
  <div class="container">
    <div class="navbar-header">
      <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#myNavbar">
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>                        
      </button>
    </div>
    <div class="collapse navbar-collapse" id="myNavbar">
      <ul class="nav navbar-nav navbar-right">
        <li><a href="https://sites.google.com/airliquide.com/amghr/home">HOME</a></li>
        <li><a href="https://sites.google.com/airliquide.com/amghr/pay">PAY</a></li>
        <li><a href="https://sites.google.com/airliquide.com/amghr/benefits">BENEFITS</a></li>
        <li><a href="https://sites.google.com/airliquide.com/amghr/policies">POLICIES</a></li>
        <li><a href="https://sites.google.com/airliquide.com/amghr/tatm">TA/TM</a></li>
        <li><a href="https://sites.google.com/airliquide.com/amghr/managers-toolkit">MANAGER'S TOOLKIT</a></li>
        <li><a href="https://sites.google.com/airliquide.com/amghr/hr-team">HR TEAM</a></li>
      </ul>
    </div>
  </div>
</nav>

</body>
</html>

1 个答案:

答案 0 :(得分:0)

我在代码中没有看到任何暗示它应该在新窗口中打开的内容,因此它可能是浏览器设置。就是说,您的语法略有错误。

这将在新窗口中打开:

<a href="example.com" target="_blank">Link Text</a>

这将在同一窗口中打开:

<a href="example.com" target="_self">Link Text</a>

请注意,_位于引号内。