最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Does Safari iOS9 returns a wrong value for window.innerHeight? - Stack Overflow

programmeradmin4浏览0评论

Here is my viewport meta tag :

    <meta name="viewport" content="user-scalable=no, initial-scale = 1, minimum-scale = 1, maximum-scale = 1, width=device-width">

On Safari iOS 8, window.innerHeight and $(window).height() both returns the same value: 928 on an iPad.

But on Safari iOS 9, window.innerHeight and $(window).height() returns different values: respectively 1461 and 559 on an iPhone 6s running iOS 9.0 or 1154 and 905 on an iPad mini running iOS 9.1.

Is this a bug in Safari or is it intended? Where does that 1461 e from on my iPhone? Should I be using $(window).height() (which returns the value I want) instead of window.innerHeight?

Here is my viewport meta tag :

    <meta name="viewport" content="user-scalable=no, initial-scale = 1, minimum-scale = 1, maximum-scale = 1, width=device-width">

On Safari iOS 8, window.innerHeight and $(window).height() both returns the same value: 928 on an iPad.

But on Safari iOS 9, window.innerHeight and $(window).height() returns different values: respectively 1461 and 559 on an iPhone 6s running iOS 9.0 or 1154 and 905 on an iPad mini running iOS 9.1.

Is this a bug in Safari or is it intended? Where does that 1461 e from on my iPhone? Should I be using $(window).height() (which returns the value I want) instead of window.innerHeight?

Share Improve this question edited Sep 29, 2015 at 9:36 Peppo 1,1131 gold badge12 silver badges19 bronze badges asked Sep 29, 2015 at 9:35 clemlatzclemlatz 8,0635 gold badges40 silver badges53 bronze badges
Add a ment  | 

3 Answers 3

Reset to default 6
<meta name="viewport" content="width=device-width initial-scale=1 shrink-to-fit=no">

adding "shrink-to-fit=no" to the viewport meta tag fixed an erroneous window.innerHeight value on resize for me -

https://forums.developer.apple./thread/13510

Yes, i experienced the same behavior...

Using $(window).height() seems to work, but I guess it's better to change the meta-tag.

See Here

Try to change your meta tag to..

<meta name="viewport" content="initial-scale=1.0001, minimum-scale=1.0001, maximum-scale=1.0001, user-scalable=no"/>
发布评论

评论列表(0)

  1. 暂无评论