UIWebView - get total height of contents using Javascript

Posted by Emil on Stack Overflow See other posts from Stack Overflow or by Emil
Published on 2010-06-05T09:47:50Z Indexed on 2010/06/05 9:52 UTC
Read the original article Hit count: 543

Hey.

I'm trying to use a UIWebView for displaying content higher than the screen of the iPhone, without needing to scroll in the webView itself.

For that, I need a way to get the total document size, including the scrollable area. I have tried a number of different Javascript solutions:

(document.height !== undefined) ? document.height : document.body.offsetHeight // Returns height of UIWebView
document.body.offsetHeight // Returns zero
document.body.clientHeight // Returns zero
document.documentElement.clientHeight // Returns height of UIWebView
window.innerHeight // Returns height of UIWebView -2

Can you think of any other way to do it? Thanks.

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about iphone