大佬教程收集整理的这篇文章主要介绍了javascript – 隐藏100%高度的iPhone地址栏,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
谢谢!
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);
这里是必不可少的:
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); };
以上是大佬教程为你收集整理的javascript – 隐藏100%高度的iPhone地址栏全部内容,希望文章能够帮你解决javascript – 隐藏100%高度的iPhone地址栏所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。