从非全屏 UIWebView 获取 javascript 中的设备高度

编程入门 行业动态 更新时间:2024-10-24 14:22:23
本文介绍了从非全屏 UIWebView 获取 javascript 中的设备高度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我尝试在 非全屏 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 0

Does 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 中的设备高度

本文发布于:2023-07-11 12:22:30,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1094046.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:全屏   高度   设备   javascript   UIWebView

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!