Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/69.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Html 一个页面主题引导导航链接不会指向另一个页面,但它适用于页面内的锚_Html_Css_Twitter Bootstrap_Jquery Plugins - Fatal编程技术网

Html 一个页面主题引导导航链接不会指向另一个页面,但它适用于页面内的锚

Html 一个页面主题引导导航链接不会指向另一个页面,但它适用于页面内的锚,html,css,twitter-bootstrap,jquery-plugins,Html,Css,Twitter Bootstrap,Jquery Plugins,我在我的ASP MVC 5应用程序中使用了一个引导单页主题。因为它是一个页面,所以所有导航链接都指向页面内的锚。然后我需要一个额外的链接来指向另一个页面,但它不起作用。当我看到源代码时,href很好,悬停也很好,但是单击它什么也不做。请帮我找出这个问题 问题在于: <li class="active"><a href="/ShoppingCart">Cart (2)</a></li> 我认为这是所有的代码,似乎没有任何其他影响链接。请让我知道,如

我在我的ASP MVC 5应用程序中使用了一个引导单页主题。因为它是一个页面,所以所有导航链接都指向页面内的锚。然后我需要一个额外的链接来指向另一个页面,但它不起作用。当我看到源代码时,href很好,悬停也很好,但是单击它什么也不做。请帮我找出这个问题

问题在于:

<li class="active"><a href="/ShoppingCart">Cart (2)</a></li>
我认为这是所有的代码,似乎没有任何其他影响链接。请让我知道,如果你需要更多的代码来解决这个奇怪的问题

我也试过这个:

<a href="./ShoppingCart">
重要更新


主要问题:链接处于活动状态,但它不指向链接页面。它甚至不直接指向404页面或任何内容。它只是不执行href位置。

我也经历过同样的情况,某些元素可能会与您的链接重叠,只需单独增加链接的z索引即可。

在href链接中调用类“external”,如下所示:

<a href="./ShoppingCart"class="external">

我刚刚在项目中解决了这个问题

在我的例子中,文件
plugin.js
造成了问题,因为模板本身是一个单页模板

我把这句话注释掉了:

self.$nav.on('click.onePageNav', $.proxy(self.handleClick, self));

导航中的链接工作正常。

我对模板也有类似的问题。application.js文件中有一个脚本可以实现这一点。因此,您应该能够删除 从a标记滚动类以允许重定向

/* use class="scroll" on the a element to activate*/
  $(".scroll").click(function (event) {
      event.preventDefault();
      //calculate destination place
      var dest = 0;
      if ($(this.hash).offset().top > $(document).height() - $(window).height()) {
          dest = $(document).height() - $(window).height();
      } else {
          dest = $(this.hash).offset().top - 50;
      }
      //go to destination
      $('html,body').animate({
          scrollTop: dest
      }, 1500, 'swing');

    /* Fix jumping of navigation. */
    setTimeout(function() {
        $(window).trigger('scroll');
    }, 900);

    return false;

  }); 

以下是本页上的解决方案:

打开您的控制台,然后单击检查工具,然后单击链接以打开当您单击该链接时运行的脚本。您必须声明一个if语句来表示:if(“.navbar a”=!”.external”){这里是具有外部链接的li的其余部分,现在它可以工作了}

然后将外部链接添加到具有外部链接的li标记

if (".navbar a" =! ".external"){
  $(".navbar a, footer a[href='#myPage']").on('click', function(event) {

    // Prevent default anchor click behavior
    event.preventDefault();

    // Store hash
    var hash = this.hash;

    // Using jQuery's animate() method to add smooth page scroll
    // The optional number (900) specifies the number of milliseconds it takes to scroll to the specified area
    $('html, body').animate({
      scrollTop: $(hash).offset().top
    }, 900, function(){

      // Add hash (#) to URL when done scrolling (default click behavior)
      window.location.hash = hash;
    });
  });
} 

该错误出现在平滑滚动函数
event.preventDefault()中
最好也是最简单的方法是添加
.not('.ext\u link')
到“平滑滚动”功能,开关将类似于:

$(".navbar a, footer a[href='#myPage']").not('.ext_link').on('click', function(event) {
并向所有外部链接添加一个
class=“ext\u link”

希望对您有用…

您能在fiddle或Plunk中展示该问题的工作示例吗这是我使用的工作模板。这完全是这样的:你如何处理Rouning?我非常确定路由是正常的。我的意思是,它只是在其他任何地方工作,而不是在导航菜单中。它就是不响,先生。Tesekkurler对不起,先生,增加z指数意味着什么?我不知道:(更新:我正在搜索,我想我有这个想法。在我搜索的时候,如果你能告诉我怎么做,我会很高兴。谢谢。还有一件事我忘了提到:当我点击链接时,班级变为“活动”。这是否意味着点击仍然被阻止?从你的回答中,我发现z-index没有问题,问题在于你的路由。你能展示你的路由机制吗?我更新了路由配置,这是内置配置。没什么。我想添加一些东西。在导航栏中,有三种链接类型元素,t这是徽标、主菜单和社交图标。我尝试了徽标和社交图标以及所有作品,但没有尝试主菜单。这让我发疯。我已经检查了足够多的拼写,先生,我肯定没有错过它
/* use class="scroll" on the a element to activate*/
  $(".scroll").click(function (event) {
      event.preventDefault();
      //calculate destination place
      var dest = 0;
      if ($(this.hash).offset().top > $(document).height() - $(window).height()) {
          dest = $(document).height() - $(window).height();
      } else {
          dest = $(this.hash).offset().top - 50;
      }
      //go to destination
      $('html,body').animate({
          scrollTop: dest
      }, 1500, 'swing');

    /* Fix jumping of navigation. */
    setTimeout(function() {
        $(window).trigger('scroll');
    }, 900);

    return false;

  }); 
if (".navbar a" =! ".external"){
  $(".navbar a, footer a[href='#myPage']").on('click', function(event) {

    // Prevent default anchor click behavior
    event.preventDefault();

    // Store hash
    var hash = this.hash;

    // Using jQuery's animate() method to add smooth page scroll
    // The optional number (900) specifies the number of milliseconds it takes to scroll to the specified area
    $('html, body').animate({
      scrollTop: $(hash).offset().top
    }, 900, function(){

      // Add hash (#) to URL when done scrolling (default click behavior)
      window.location.hash = hash;
    });
  });
} 
$(".navbar a, footer a[href='#myPage']").not('.ext_link').on('click', function(event) {