检测负载时的手机方向
是否可以在页面加载时使用 Javascript 检查。我知道您可以检测到方向的变化,但是是否可以立即检查手机处于什么状态?
谢谢
Is this possible to check with Javascript on page load. I know you can detect a change in orientation but is it possible to check what state the phone is in straight away?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
![扫码二维码加入Web技术交流群](/public/img/jiaqun_03.jpg)
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以检查视口宽度和高度,看看哪一个更大:
有关移动设备上视口尺寸的更深入讨论,请参阅
http://www.quirksmode.org/mobile/viewports2.html
(更新的代码)
You could check the viewport width and height and see which one is larger:
For a more in-depth discussion of viewport sizes on mobile devices, see
http://www.quirksmode.org/mobile/viewports2.html
(Updated code)
你可以这样做...
orientationINIT 应该在页面加载或 DOM 完成时(或在页面底部)调用
,其中 getHeight() 和 getWidth() 应该是简单的函数,以数字形式返回窗口的宽度/高度。
You can do this...
orientationINIT should be called on page load or DOM complete (or at the bottom of the page )
where getHeight() and getWidth() should be simple functions that return the window's width / height in number form.