.animate()适用于Firefox、Chrome和IE9,但不适用于IE10(Jquery 1.8.3和1.9.1



编辑:固定:感谢大家的帮助。

问题是CSS代码中的这一孤立行:

  • {转换:所有0.2s轻松;}

删除此线路修复了问题

原始帖子:

在中断了10年之后,我才刚刚开始编码。我正在尝试获得一些代码来制作从页面中间到顶部的菜单动画。它适用于Firefox、Chrome和IE9,但在IE10中被破坏。我尝试过JQuery 1.6.3和1.9.2,但都没有解决方案。

编辑:菜单悬停在IE10中工作良好。我所说的breaked是指IE10中的菜单没有动画。IE10中的控制台中没有javascript错误。在IE10中,点击确实可以很好地捕捉到,因为window.location.href确实正确地更改为appointments.html。

代码段:

<header id="menubar" style="top: 496px; left: 80px; width: 1360px;">
  <ul id="surnav">
    <li class="menu-hover"> <a href=
      "index.html">Home</a> </li>
    <li id="appointments" class="menu-hover"> <a href=
      "#">Appointments</a> <img src="norwood_files/snav-arrow.png" width="10" height="5" />
      <ul class="submenu">
        <li>Emergencies</li>
      </ul>
    </li>
  </ul>
</header>

JavaScript:

$(document).ready(function () {
if (document.URL.indexOf("index.html") >= 0) {
    $("#menubar").css("top", "496px");
    $(".menu-hover").on({
        click: function () {
            $("#menubar").animate({
                top: '50px'
            }, "easing:swing");
        },
        mouseenter: function () {
            $(this).children(".submenu, img").fadeIn(250);
        },
        mouseleave: function () {
            $(this).children(".submenu, img").fadeOut(250);
        }
    });
    $("#appointments").on({
        click: function () {
            $("#appointments-bkg").animate({
                top: '-14px'
            }, "easing:swing", function () {
                window.location.href = "appointments.html"
            });
        }
    });
    $("#financial").on({
        click: function () {
            $("#financial-bkg").animate({
                top: '-14px'
            }, "easing:swing", function () {
                window.location.href = "financial.html"
            });
        }
    });
}
});

谢谢!

也许可以尝试if(window.location.href.match(/index.html/i)而不是if(document.URL.indexOf("index.html") >= 0)。除此之外,考虑到所有其他浏览器都很好,我不明白为什么它在IE10中不起作用。

最新更新