[TIMOB-18788] Android: evalJS("document.height") returns undefined on Android 4.4.4
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | Critical |
Status | Closed |
Resolution | Not Our Bug |
Resolution Date | 2015-06-16T02:15:13.000+0000 |
Affected Version/s | Release 3.5.1 |
Fix Version/s | Release 4.1.0 |
Components | Android |
Labels | android, evaljs, webview |
Reporter | David IAV |
Assignee | Ashraf Abu |
Created | 2014-07-22T12:09:10.000+0000 |
Updated | 2015-06-19T22:10:55.000+0000 |
Description
Quering a webview to get the height of the content using webview.evalJS("document.height") works fine on Android 4.4.2 (tested on HTC One) and lower devices, but Android 4.4.4 devices (tested on the Nexus 5 and 7) returns undefined instead of the height of the content. Sample code:
{noformat}
body.addEventListener('load', function(e) {
var h = body.evalJS("document.height");
Ti.API.info("Content height: " + h); // returns height on < 4.4.2, undefined on 4.4.4
}
{noformat}
Ok. No problem. Test case is following:
Hi, I had the very same issue, but as a fix, instead of relying on document.height I now use the following which seems to work perfectly:
Kai
I think [~kaiiserni] is correct. I'm just looking around and it seems like for Mozilla [https://developer.mozilla.org/en-US/docs/Web/API/Document/height] which is following the HTML5 specification standard: {quote} Note: Starting in Gecko 6.0, document.height is no longer supported. Instead use document.body.clientHeight. See element.clientHeight. {quote} And for Android, [https://developer.android.com/guide/webapps/migrating.html] the WebView was changed on Android 4.4 onwards to Chromium. This is possibly why this behavior changed from Android 4.4.4 onwards. {quote} This change upgrades WebView performance and standards support for HTML5, CSS3, and JavaScript to match the latest web browsers {quote} Therefore, I believe the best answer would be [~kaiiserni]'s answer (thanks for your comment!), which is to use:
You shouldn't be using 'document.height'. I believe this should be the answer and the ticket can be resolved as Invalid. [~mrahman] Would this be okay for you?
If there's nothing else, I'll close this ticket tomorrow.