Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/75.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
Jquery scrollTop()未滚动到IE windows 8 phone上的正确位置_Jquery_Internet Explorer_Mobile_Windows Mobile - Fatal编程技术网

Jquery scrollTop()未滚动到IE windows 8 phone上的正确位置

Jquery scrollTop()未滚动到IE windows 8 phone上的正确位置,jquery,internet-explorer,mobile,windows-mobile,Jquery,Internet Explorer,Mobile,Windows Mobile,它在任何地方都可以正常工作,虽然浏览器返回正确的高度,但它会滚动到错误的位置(每次都不同)。这只发生在IE W8手机上,下面是代码: $("#navigation-wrapper a").click(function(e){ $headerHeight = $("#header").height(); var $anchor = $(this); $('html, body').stop().animate({scrollTop: $($anchor.attr('href

它在任何地方都可以正常工作,虽然浏览器返回正确的高度,但它会滚动到错误的位置(每次都不同)。这只发生在IE W8手机上,下面是代码:

$("#navigation-wrapper a").click(function(e){
    $headerHeight = $("#header").height();
    var $anchor = $(this);
    $('html, body').stop().animate({scrollTop: $($anchor.attr('href')).offset().top - $headerHeight});
e.preventDefault(); });

有什么想法吗?

虽然这很混乱,但出于某种原因,它起了作用。为了滚动到正确的位置,我不得不调用animate两次

$('html, body').stop()
  .animate({scrollTop: $($anchor.attr('href')).offset().top - $headerSize},function(){
      $('html, body').stop()
        .animate({scrollTop: $($anchor.attr('href')).offset().top - $headerSize});
    });

我也注意到了这一点。对我来说,它也在反弹,而它本不应该反弹,所以我假设它是一个jQuery bug。