简体   繁体   English

Scrollspy-在导航上单击Chrome滚动,IE和FF不会

[英]Scrollspy - on nav click Chrome scrolls, IE & FF doesn't

Clicking on navbar scrolls the page correctly in Chrome, nothing happens in FF and IE. 单击导航栏可在Chrome中正确滚动页面,而在FF和IE中则没有任何反应。 Any idea? 任何想法? Here's a part of my nav's jsx: 这是我的导航jsx的一部分:

handleOnClick (e) {
    e.preventDefault();
    if (this.props.show) {
        var target = $(e.target.parentElement);
        var el = $('#section-' + this.props.id);
        $('.list-group-item').removeClass('active');
        $('.scrollspy').removeClass('scrollspy-active');
        target.addClass('active');
        $('body').animate(
            {scrollTop: (el.offset().top - 20)},
            {
                duration: 200,
                done: () => {
                    $('.scrollspy').addClass('scrollspy-active'); 
                }
            });
        this.props.onSelected(e, this.props.id);
        if ($(window).width() <= 992) {
            $('.collapse').collapse('hide');
        }
    }
};

UPDATE: And here's my nav.html. 更新:这是我的nav.html。 Forgive me if it's too much. 如果太多,请原谅我。 Forums say that there used to be a scrollspy's problem regarding FF and IE that was releted to height but it doesn't seem to be that one. 论坛上说,以前关于FF和IE的问题一直被反复提及,但似乎并非如此。

<div class="navbar navbar-default navbar-fixed-top" role="navigation">
  <div class="container">

      <!-- Main navigation -->
      <ul class="nav navbar-nav">
        {% for nav_item in nav %}
        {% if nav_item.children %}
        <li class="dropdown{% if nav_item.active %} active{% endif %}">
          <a href="#" class="dropdown-toggle" data-toggle="dropdown">{{ nav_item.title }} <b class="caret"></b></a>
          <ul class="dropdown-menu">
            {% for nav_item in nav_item.children %}
            {% include "nav-sub.html" %}
            {% endfor %}
          </ul>
        </li>
        {% else %}
        <li {% if nav_item.active %}class="active"{% endif %}>
          <a href="{{ nav_item.url }}">{{ nav_item.title }}</a>
        </li>
        {% endif %}
        {% endfor %}
      </ul>
      {% endif %}
      <ul class="nav navbar-nav navbar-right">
        {% if repo_url %}
        <li>
          <a href="{{ repo_url }}">
            {% if repo_name == 'GitHub' %}
            <i class="fa fa-github"></i>
            {% elif repo_name == 'Bitbucket' %}
            <i class="fa fa-bitbucket"></i>
            {% endif %}
            {{ repo_name }}
          </a>
        </li>
        {% endif %}
      </ul>
    </div>

It was about changing 这是关于改变

$('body').animate(

to

$('html,body').animate(

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 <a href doesn't fire after .Click jquery function call in IE. Works fine with Chrome and FF - <a href doesn't fire after .Click jquery function call in IE. Works fine with Chrome and FF jQuery scrollTop不会在FF或IE中创建动画,但在chrome中可以正常工作 - jQuery scrollTop doesn't animate in FF or IE but working fine in chrome SWF不会在IE9中呈现(但会在Chrome / FF中呈现) - SWF doesn't render in IE9 (but does in Chrome/FF) iFrame 在 Chrome 中不起作用(在 FF、IE 和 Safari 中工作正常) - iFrame doesn't work in Chrome (works fine in FF, IE and Safari) JS在IE上工作,不适用于chrome和FF - JS that work on IE and doesn't work on chrome and FF 引导scrollspy在IE中不起作用? - Bootstrap scrollspy doesn't works in ie? <a href=“..”>第一次点击不起作用,但在FF中第二次点击起作用,在IE中工作正常</a> - <a href=“..”> doesn't work at first click but works at second click in FF, in IE works fine Angularjs导出到Excel-在IE中不起作用,并且Excel在ff和chrome中不正确 - Angularjs Export to Excel - doesn't work in IE, and excel not proper in ff and chrome 链接在 <select>使用JS不适用于Chrome。 IE&FF它的工作原理 - Link in a <select> with JS doesn't work on Chrome. IE & FF it works 在IE 9之前无法使用的Javascript / jquery代码在FF,Chrome,Safari中正常运行 - Javascript/jquery code that doesn't work prior to IE 9. Works fine in FF, Chrome, Safari
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM