在iOS 10 beta上的Safari中,window.outerWidth为0 [英] window.outerWidth is 0 in Safari on iOS 10 beta
问题描述
使用安装了iOS 10的iPad,我在浏览器控制台中输入了 window.outerWidth
,其值为 0
。 OTOH, window.innerWidth
正确生成 1024
(横向模式)。
Using an iPad with iOS 10 installed, I entered window.outerWidth
in the browser console and got a value of 0
. OTOH, window.innerWidth
correctly produced 1024
(landscape mode).
在iOS 9中, window.outerWidth
正确生成 1024
,这只是iOS中的一个错误10 beta还是我缺少这个属性的微妙之处?
In iOS 9, window.outerWidth
correctly produced 1024
, so is this just a bug in the iOS 10 beta or is there a subtlety to this property that I'm missing?
推荐答案
如果你在项目中使用jQuery ,你可以使用 $(window).outerWidth()
和 $(window).outerHeight()
。这是一种在所有设备中按预期工作的解决方法。
If you're using jQuery in your project, you can use $(window).outerWidth()
and $(window).outerHeight()
. It's a workaround that works as expected in all devices.
这篇关于在iOS 10 beta上的Safari中,window.outerWidth为0的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!