JavaScript   发布时间:2022-04-16  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了javascript – 隐藏100%高度的iPhone地址栏大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
许多帖子在这个,但不太适合我的情况.我的页面具有灵活的尺寸设置为100%宽度和100%高度,因此典型的负载滚动功能不起作用.任何想法或其他解决方案?

谢谢!

CSS:

* {
    margin:0;
    padding:0;
}
html,body {
    width:100%;
    height:100%;
    min-width:960px;
    overflow:hidden;
}

使用Javascript:

/mobile/i.test(navigator.userAgent) && !pageYOffset && !location.hash && setTimeout(function () {
  window.scrollTo(0,1);
    },1000);​

解决方法

来自Nate Smith的这个解决方案帮助我: How to Hide the Address Bar in a Full Screen Iphone or Android Web App.

这里是必不可少的:

var page   = document.getElementById('page'),ua     = navigator.userAgent,iphone = ~ua.indexOf('iPhone') || ~ua.indexOf('iPod');

var setupScroll = window.onload = function() {
  // Start out by adding the height of the location bar to the width,so that
  // we can scroll past it
  if (ios) {
    // iOS reliably returns the innerWindow size for documentElement.clientHeight
    // but window.innerHeight is sometimes the wrong value after rotating
    // the orientation
    var height = document.documentElement.clientHeight;
    // Only add extra padding to the height on iphone / ipod,since the ipad
    // browser doesn't scroll off the location bar.
    if (iphone && !fullscreen) height += 60;
    page.style.height = height + 'px';
  }
  // Scroll after a timeout,since iOS will scroll to the top of the page
  // after it fires the onload event
  setTimeout(scrollTo,1);
};

有关更多详情,请查看他的blog postGist.

大佬总结

以上是大佬教程为你收集整理的javascript – 隐藏100%高度的iPhone地址栏全部内容,希望文章能够帮你解决javascript – 隐藏100%高度的iPhone地址栏所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。
标签: