问题
All the answers on SO for fetching the device's height seem based on jQuery. We need something in pure JavaScript before the jQuery code loads.
回答1:
document.documentElement.clientHeight
There are a number of other methods, too: http://responsejs.com/labs/dimensions/
回答2:
May be a little late, but use window.screen.height
回答3:
In most cases, $(window).height(); does the job. However, on iOS, it gives wrong results because of the toolbars, same as $(window).outerHeight();. The right value to use is window.outerHeight.
Try this :
(typeof window.outerHeight != 'undefined')?Math.max(window.outerHeight, $(window).height()):$(window).height()
来源:https://stackoverflow.com/questions/18243571/get-window-height-on-mobile-devices-especially-iphones-without-using-jquery