iOS返回window.innerHeight / Width的错误值 [英] iOS return bad value for window.innerHeight/Width

查看:280
本文介绍了iOS返回window.innerHeight / Width的错误值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 window.innerHeight window.innerWidth 说明来获取浏览器的可用窗口大小。它正在使用firefox,safari(在Mac上)和android,但我在iOS中得到了奇怪的结果。

I'm using window.innerHeight and window.innerWidth instructions to get the browser's available window size. It's working with firefox, safari (on a mac) and android but I get strange results in iOS.

iOS总是返回innerHeight = 1091和innerWidth = 980。

iOS always returns innerHeight=1091 and innerWidth=980.

我正在使用iOS SDK中的iOS模拟器(我没有iPhone / iPod)。 iPhone和iPhone Retina仿真器返回相同的值。我不明白他们如何能够返回相同的数字,因为2个模型有2种不同的屏幕分辨率。

I'm using iOS emulator from the iOS SDK (I don't own an iPhone/iPod). The same value is returned with the iPhone and iPhone Retina emulator. I don't understand how they can both returns the same numbers because the 2 models have 2 different screens resolutions.

我使用viewport参数但没有成功。

I played with the viewport parameter with no success.

推荐答案

尝试使用 screen.width 而不是 window.innerWidth

<script>
  if (screen.width > 650) {
    ....
  }
</script>

这篇关于iOS返回window.innerHeight / Width的错误值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆