问题
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
.
回答1:
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.
回答2:
Did u used this document.write("Total Height: " + screen.height);
screen.height
,
The height property returns the total height of the visitor's screen, in pixels.
来源:https://stackoverflow.com/questions/14155907/get-device-height-in-javascript-from-non-full-screen-uiwebview