{ "id": "133520", "key": "TIMOB-18788", "fields": { "issuetype": { "id": "1", "description": "A problem which impairs or prevents the functions of the product.", "name": "Bug", "subtask": false }, "project": { "id": "10153", "key": "TIMOB", "name": "Titanium SDK/CLI", "projectCategory": { "id": "10100", "description": "Titanium and related SDKs used in application development", "name": "Client" } }, "fixVersions": [ { "id": "16723", "description": "Windows Platform Support, ListView updates, Vector overlays in maps", "name": "Release 4.1.0", "archived": false, "released": true, "releaseDate": "2015-07-08" } ], "resolution": { "id": "11", "description": "Is not a bug in our product", "name": "Not Our Bug" }, "resolutiondate": "2015-06-16T02:15:13.000+0000", "created": "2014-07-22T12:09:10.000+0000", "priority": { "name": "Critical", "id": "1" }, "labels": [ "android", "evaljs", "webview" ], "versions": [ { "id": "16711", "description": "Release 3.5.1", "name": "Release 3.5.1", "archived": false, "released": true, "releaseDate": "2015-03-06" } ], "issuelinks": [], "assignee": { "name": "msamah", "key": "msamah", "displayName": "Ashraf Abu", "active": false, "timeZone": "Asia/Singapore" }, "updated": "2015-06-19T22:10:55.000+0000", "status": { "description": "The issue is considered finished, the resolution is correct. Issues which are closed can be reopened.", "name": "Closed", "id": "6", "statusCategory": { "id": 3, "key": "done", "colorName": "green", "name": "Done" } }, "components": [ { "id": "10202", "name": "Android", "description": "Android Platform" } ], "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:\r\n\r\n{noformat}\r\nbody.addEventListener('load', function(e) {\r\n\tvar h = body.evalJS(\"document.height\");\r\n\tTi.API.info(\"Content height: \" + h); // returns height on < 4.4.2, undefined on 4.4.4\r\n}\r\n{noformat}\r\n", "attachment": [], "flagged": false, "summary": "Android: evalJS(\"document.height\") returns undefined on Android 4.4.4", "creator": { "name": "DavidIAV", "key": "davidiav", "displayName": "David IAV", "active": true, "timeZone": "America/Los_Angeles" }, "subtasks": [], "reporter": { "name": "DavidIAV", "key": "davidiav", "displayName": "David IAV", "active": true, "timeZone": "America/Los_Angeles" }, "environment": "Titanium SDK 3.2.3.GA\r\nAndroid 4.4.4 (Nexus 5/7)\r\nAndroid 4.4.2 (HTC One)", "closedSprints": [ { "id": 416, "state": "closed", "name": "2015 Sprint 12 SDK", "startDate": "2015-06-06T00:00:43.862Z", "endDate": "2015-06-20T00:00:00.000Z", "completeDate": "2015-06-23T05:41:35.834Z", "originBoardId": 114 } ], "comment": { "comments": [ { "id": "316610", "author": { "name": "sliang", "key": "sliang", "displayName": "Shuo Liang", "active": true, "timeZone": "Asia/Harbin" }, "body": "Ok. No problem.\r\n\r\nTest case is following:\r\n\r\n{code}\r\nvar win = Ti.UI.createWindow();\r\n\r\nvar webview = Ti.UI.createWebView({\r\n url: 'http://www.google.com'\r\n});\r\nwin.add(webview);\r\n \r\nwebview.addEventListener('load',function(e) {\r\n var l = webview.evalJS(\"document.height\"); \r\n Ti.API.info(\"Context Length \" + l);\r\n});\r\n\r\nwin.open();\r\n{code}", "updateAuthor": { "name": "sliang", "key": "sliang", "displayName": "Shuo Liang", "active": true, "timeZone": "Asia/Harbin" }, "created": "2014-08-01T06:30:00.000+0000", "updated": "2014-08-01T06:30:00.000+0000" }, { "id": "332411", "author": { "name": "kaiiserni", "key": "kaiiserni", "displayName": "Kai De Sutter", "active": true, "timeZone": "Europe/Berlin" }, "body": "Hi,\r\n\r\nI 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:\r\n{code:javascript}\r\nvar _height = _html_view.evalJS(\"Math.max(document.body.scrollHeight, document.body.offsetHeight, document.documentElement.clientHeight, document.documentElement.scrollHeight, document.documentElement.offsetHeight);\");\r\nHope this helps!\r\n{code}\r\nKai", "updateAuthor": { "name": "kaiiserni", "key": "kaiiserni", "displayName": "Kai De Sutter", "active": true, "timeZone": "Europe/Berlin" }, "created": "2014-11-17T10:02:11.000+0000", "updated": "2014-11-17T10:02:11.000+0000" }, { "id": "354848", "author": { "name": "msamah", "key": "msamah", "displayName": "Ashraf Abu", "active": false, "timeZone": "Asia/Singapore" }, "body": "I think [~kaiiserni] is correct.\r\n\r\nI'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:\r\n{quote}\r\nNote: Starting in Gecko 6.0, document.height is no longer supported. Instead use document.body.clientHeight. See element.clientHeight.\r\n{quote}\r\nAnd 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.\r\n{quote}\r\nThis change upgrades WebView performance and standards support for HTML5, CSS3, and JavaScript to match the latest web browsers\r\n{quote}\r\n\r\nTherefore, I believe the best answer would be [~kaiiserni]'s answer (thanks for your comment!), which is to use:\r\n{code}\r\nvar _height = _html_view.evalJS(\"Math.max(document.body.scrollHeight, document.body.offsetHeight, document.documentElement.clientHeight, document.documentElement.scrollHeight, document.documentElement.offsetHeight);\");\r\n{code}\r\n\r\nYou shouldn't be using 'document.height'.\r\n\r\nI believe this should be the answer and the ticket can be resolved as Invalid.\r\n\r\n[~mrahman] Would this be okay for you?", "updateAuthor": { "name": "msamah", "key": "msamah", "displayName": "Ashraf Abu", "active": false, "timeZone": "Asia/Singapore" }, "created": "2015-06-11T05:13:15.000+0000", "updated": "2015-06-11T05:26:44.000+0000" }, { "id": "355092", "author": { "name": "msamah", "key": "msamah", "displayName": "Ashraf Abu", "active": false, "timeZone": "Asia/Singapore" }, "body": "If there's nothing else, I'll close this ticket tomorrow.", "updateAuthor": { "name": "msamah", "key": "msamah", "displayName": "Ashraf Abu", "active": false, "timeZone": "Asia/Singapore" }, "created": "2015-06-15T03:05:17.000+0000", "updated": "2015-06-15T03:05:17.000+0000" } ], "maxResults": 6, "total": 6, "startAt": 0 } } }