Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does Safari iOS9 returns a wrong value for 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 come from on my iPhone? Should I be using $(window).height() (which returns the value I want) instead of window.innerHeight?

like image 970
Iwazaru Avatar asked Sep 29 '15 09:09

Iwazaru


3 Answers

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

like image 173
sherrmann Avatar answered Oct 20 '22 01:10

sherrmann


<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.com/thread/13510

like image 6
user3032404 Avatar answered Oct 20 '22 02:10

user3032404


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"/>
like image 2
benmore99 Avatar answered Oct 20 '22 03:10

benmore99