Get window height on mobile devices (especially iPhones) without using jQuery

守給你的承諾、 提交于 2019-12-09 05:20:11

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!