我尝试在 非全屏 UIWebview (320x216) 和 javascript 中区分 Iphone 5 设备.我使用屏幕高度作为开关,因为这似乎 仅 方式在 javascript 中执行此操作.>
问题在于,通常的做法是报告 0 或 UIWebview 的高度,而不是设备的高度.
document.body.offsetHeight//返回216screen.availHeight//返回0document.documentElement.clientHeight//返回216window.innerHeight//返回216screen.height//返回0有人知道这样做的方法吗?不幸的是,我无法控制 UIWebview 的目标 c 代码.
解决方案我知道你说过你已经尝试过了,但是 screen.availHeight 对于 iPhone 5 返回 568,即使实际 UIWebView 框架要小得多(即 216).我使用的是 iOS 7.
I try to distinguish an Iphone 5 device in a non full screen UIWebview (320x216) from javascript. I am using the screen height as switch as that seems the only way to do this in javascript.
The problem is that the usual way to do this reports either 0 or the height of the UIWebview, not the height of the device.
document.body.offsetHeight //returns 216 screen.availHeight //returns 0 document.documentElement.clientHeight //returns 216 window.innerHeight //returns 216 screen.height //returns 0Does anybody know of a method to do this? I unfortunately don't have control over the objective c code for the UIWebview.
解决方案I know you said you tried this already but screen.availHeight returns 568 for an iPhone 5, even when the actual UIWebView frame is much smaller (i.e. 216). I am on iOS 7.
更多推荐
从非全屏 UIWebView 获取 javascript 中的设备高度
发布评论