我目前在使用Chrome Mobile 71版时遇到麻烦。

问题是下面的地址栏。我尝试使用:

<script>
   alert($(window).innherHeight())
   alert($(window).outerHeight())
   alert($(window).height())
</script>


它们都返回相同的高度,但是由于地址栏的原因,它们不应该返回相同的高度。那么,有什么问题呢?当我尝试在网页中放置页脚时(通过使用绝对位置和底部位置:0),该页脚会正确显示在手机上的Firefox和chrome mobile的笔记本电脑中(因为没有地址栏) 。但是,在我的android中的chrome应用程序中,直到我到达页面末尾,页脚才出现。

我尝试了一些解决方法:

window.addEventListener("load",function() {
    setTimeout(function(){
            // This hides the address bar:
            window.scrollTo(0, 1);

    }, 0);
});


和我在其他答案中发现的相似之处。但是,它们要么不起作用,要么即使起作用,它们也会使地址栏消失时(因为用户到达页面末尾或类似内容)使网页看起来很糟糕。

有人可以帮忙吗?

谢谢

最佳答案

好吧,这不是最佳答案,但坦率地说,这是对我更好的解决方案:

if(navigator.userAgent.indexOf("Chrome") != -1 && navigator.userAgent.indexOf("Mobile") != -1){
    $('body').css("max-height", $(window).outerHeight());
    $('body').css("min-height", $(window).outerHeight());
    $( window ).resize(function(e) {
      $('body').css("max-height", $(window).outerHeight());
      $('body').css("min-height", $(window).outerHeight());
  });
}

10-04 12:34