0

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.

Community
  • 1
  • 1
RickyA
  • 15,465
  • 5
  • 71
  • 95

2 Answers2

0

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.

TPoschel
  • 3,775
  • 2
  • 30
  • 29
-1

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.

ameya rote
  • 1,116
  • 1
  • 9
  • 13
  • `screen.height` returns 0. – RickyA Jan 04 '13 at 11:10
  • Please put your code on fiddle. to help you more. Check this fiddle http://jsfiddle.net/YRrpZ/ – ameya rote Jan 04 '13 at 11:11
  • I cant create objective c code there. So it would not be really useful. I dont want people to open the link in ios safari and the comment that it works ok. The point is that that the javascript is loaded from a non full screen UIWebview. – RickyA Jan 04 '13 at 11:14
  • See that fiddle is working fine and returns exact screen height. you might have misplaced something please check once. 'screen.height' – ameya rote Jan 04 '13 at 11:16