Wrong Window / Viewport Dimensions on iOS

2014-07-14 | #ios, #jquery, #solution

This seems to be a jQuery bug:

$(window).height() and such will return values not exactly fitting the current viewport height. Instead you'll have to use a construction such as:

var height = window.innerHeight || $(window).height();

jQuery seems to calculate the dims in these cases with an algorithm not correctly handling address and or toolbars of Mobile Safari. Nothing too dramatic, but another quirk to keep in mind forever. -.-