a href onclick =并不适用于所有子页面

时间:2018-04-10 08:41:02

标签: javascript html

我在网站的9个子页面中有以下代码,其中7个代码的工作方式与预期完全一致。 但在另外两页上它不起作用,我无法弄清楚原因。



<div class="inner-offset darken-block">
  <div class="container-fluid">
    <ul class="nav nav-tabs wow zoomIn" data-wow-delay="0.3s" id="filter">
      <li><a href onclick="location.href='07_services.html'">All services</a></li>
      <li><a href onclick="location.href='systems_set-up.html'">SYSTEM-SET-UP</a></li>
      <li><a href onclick="location.href='warehousing.html'">WAREHOUSING</a></li>
      <li><a href onclick="location.href='pre-sales_management.html'">PRE SALES MANAGEMENT</a></li>
      <li class="active"><a href onclick="location.href='pick_and_pack.html'">PICK & PACK</a></li>
      <li><a href onclick="location.href='delivery.html'">DELIVERY</a></li>
      <li><a href onclick="location.href='after_sales_management.html'">AFTER SALES MANAGEMENT</a></li>
      <li><a href onclick="location.href='value_added_services.html'">VALUE ADDED SERVICES</a></li>
      <li><a href onclick="location.href='prices.php'">PREISE</a></li>
    </ul>
  </div>
</div>
&#13;
&#13;
&#13;

不起作用的页面中的代码如下:

&#13;
&#13;
<div class="inner-offset darken-block">
  <div class="container-fluid">
    <ul class="nav nav-tabs wow zoomIn" data-wow-delay="0.3s" id="filter">
      <li><a href onclick="location.href='07_services.html'">All services</a></li>
      <li><a href onclick="location.href='systems_set-up.html'">SYSTEM-SET-UP</a></li>
      <li><a href onclick="location.href='warehousing.html'">WAREHOUSING</a></li>
      <li><a href onclick="location.href='pre-sales_management.html'">PRE SALES MANAGEMENT</a></li>
      <li><a href onclick="location.href='pick_and_pack.html'">PICK & PACK</a></li>
      <li><a href onclick="location.href='delivery.html'">DELIVERY</a></li>
      <li class="active"><a href onclick="location.href='after_sales_management.html'">AFTER SALES MANAGEMENT</a></li>
      <li><a href onclick="location.href='value_added_services.html'">VALUE ADDED SERVICES</a></li>
      <li><a href onclick="location.href='prices.php'">PREISE</a></li>
    </ul>
  </div>
</div>
&#13;
&#13;
&#13;

链接不起作用。我在浏览页面时单击链接,它没有响应按照链接并加载页面。

3 个答案:

答案 0 :(得分:1)

我不明白为什么你使用onclick属性进行超文本引用。我会说使用href属性。像这样:

<div class="inner-offset darken-block">
  <div class="container-fluid">
    <ul class="nav nav-tabs wow zoomIn" data-wow-delay="0.3s" id="filter">
      <li><a href="0.7_services.html">All services</a></li>
     

答案 1 :(得分:0)

请尝试以下代码:

<script >
    function jumpon(uri){
        document.location = "http://localhost/" + uri;
    }

</script>
<div class="inner-offset darken-block">
<div class="container-fluid">
    <ul class="nav nav-tabs wow zoomIn" data-wow-delay="0.3s" id="filter">
    <li><a href="#" onclick="javascript:jumpon('07_services.html');">All services</a></li>
    <li><a href="#" onclick="javascript:jumpon('systems_set-up.html');">SYSTEM-SET-UP</a></li>
    <li><a href="#" onclick="javascript:jumpon('warehousing.html');">WAREHOUSING</a></li>
    <li><a href="#" onclick="javascript:jumpon('pre-sales_management.html');">PRE SALES MANAGEMENT</a></li>
    <li class="active"><a href="#" onclick="javascript:jumpon('pick_and_pack.html');">PICK & PACK</a></li>
    <li><a href="#" onclick="javascript:jumpon('delivery.html');">DELIVERY</a></li>
    <li><a href="#" onclick="javascript:jumpon('after_sales_management.html');">AFTER SALES MANAGEMENT</a></li>
    <li><a href="#" onclick="javascript:jumpon('value_added_services.html');">VALUE ADDED SERVICES</a></li>
    <li><a href="#" onclick="javascript:jumpon('prices.php');">PREISE</a></li>
    </ul>
</div>
</div>

答案 2 :(得分:-1)

你可以试试这个。

 <ul class="nav nav-tabs wow zoomIn" data-wow-delay="0.3s" id="filter">
          <li><a href="#" id="abc" onclick="func(); return false;">All services</a></li>
     </ul>
    <script type="text/javascript">
      function func()
      {
        document.getElementById("abc").href="service.html"; 
      }
    </script>