{ "id": "174518", "key": "TIMOB-27644", "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": [], "resolution": null, "resolutiondate": null, "created": "2019-12-06T19:58:13.000+0000", "priority": { "name": "Critical", "id": "1" }, "labels": [ "engTriage" ], "versions": [ { "id": "20832", "name": "Release 8.3.0", "archived": false, "released": true, "releaseDate": "2019-11-25" } ], "issuelinks": [], "assignee": { "name": "ybanev", "key": "ybanev", "displayName": "Yordan Banev", "active": true, "timeZone": "Europe/Athens" }, "updated": "2019-12-09T16:32:57.000+0000", "status": { "description": "The issue is open and ready for the assignee to start work on it.", "name": "Open", "id": "1", "statusCategory": { "id": 2, "key": "new", "colorName": "blue-gray", "name": "To Do" } }, "components": [ { "id": "10202", "name": "Android", "description": "Android Platform" } ], "description": "On Android, a webview opens new window with webview if link target is \"_blank\". This does not happen on iOS and should not happen except the developer explicitly wants a new window.\r\n\r\nExample:\r\n{code:js}\r\nvar win = Ti.UI.createWindow({ title: 'Test Window' });\r\nvar webView = Ti.UI.createWebView({\r\n html: 'Click me!'\r\n});\r\nwebView.addEventListener('beforeload', function (event) {\r\n if (event.url.includes('google.com')) {\r\n alert('STOP LOADING');\r\n webView.stopLoading();\r\n }\r\n});\r\nwin.add(webView);\r\nwin.open();\r\n{code}\r\n\r\nAny workaround is appreciated. The {{blacklistedURLs}} property also does not help.\r\n\r\n*EDIT*: There is an old [{{onCreateWindow}}|https://docs.appcelerator.com/platform/latest/#!/api/Titanium.UI.WebView-property-onCreateWindow] property which is meant to handle _blank links, but unfortunately, returning {{null}} there does also not stop the new window from popping up. Same for returning {{false}} in the {{onLink}} property.", "attachment": [], "flagged": false, "summary": "Android: Webview opens new window with webview if link target is \"_blank\"", "creator": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "subtasks": [], "reporter": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "environment": null, "comment": { "comments": [ { "id": "453069", "author": { "name": "michael", "key": "michael", "displayName": "Michael Gangolf", "active": true, "timeZone": "Europe/Berlin" }, "body": "I think this should help: http://docs.appcelerator.com/platform/latest/#!/api/Titanium.UI.WebView-property-onCreateWindow\r\n{code}\r\nwebView.onCreateWindow = function(e) {\r\n\treturn null; // don't open popup links\r\n};\r\n{code}\r\nor expose this property: https://github.com/appcelerator/titanium_mobile/blob/13658500189a8de1c8fa9773518fbe0ee7947036/android/modules/ui/src/java/ti/modules/titanium/ui/widget/webview/TiUIWebView.java#L318 and set it to false (which would be a good idea)", "updateAuthor": { "name": "michael", "key": "michael", "displayName": "Michael Gangolf", "active": true, "timeZone": "Europe/Berlin" }, "created": "2019-12-06T20:14:56.000+0000", "updated": "2019-12-06T20:14:56.000+0000" }, { "id": "453070", "author": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "body": "Just tried that and unfortunately it does not work. Disabling the above property will probably help, will build a custom SDK again. For parity with iOS, it should even be disabled by property, preventing multiple windows from being opened.\r\n\r\n*EDIT*: Holy moly. Assigning the property after creation works. De-escalated, thanks Michael! But hopefully this can be properly fixed in 9.0.0.\r\n\r\n*EDIT 2*: Unfortunately this does also not work, because the {{beforeload}} event does not fire anymore at all.", "updateAuthor": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "created": "2019-12-06T20:18:07.000+0000", "updated": "2019-12-06T20:24:28.000+0000" }, { "id": "453071", "author": { "name": "michael", "key": "michael", "displayName": "Michael Gangolf", "active": true, "timeZone": "Europe/Berlin" }, "body": "{code}\r\nvar win = Ti.UI.createWindow({\r\n\ttitle: 'Test Window'\r\n});\r\n\r\nvar webView = Ti.UI.createWebView({\r\n\thtml: 'external link - internal link'\r\n});\r\n\r\nwebView.addEventListener('beforeload', function(event) {\r\n\tif (event.url.includes('google.com')) {\r\n\t\talert('STOP LOADING');\r\n\t\twebView.stopLoading();\r\n\t}\r\n});\r\n\r\nvar tmpWebView = Ti.UI.createWebView({\r\n\tvisible:false\r\n});\r\n\r\nwebView.onCreateWindow = function(e) {\r\n\treturn tmpWebView;\r\n};\r\n\r\nwin.add(webView);\r\nwin.open();\r\n{code}\r\n\r\nThat will trigger the alert for the external link. ", "updateAuthor": { "name": "michael", "key": "michael", "displayName": "Michael Gangolf", "active": true, "timeZone": "Europe/Berlin" }, "created": "2019-12-06T20:29:42.000+0000", "updated": "2019-12-06T20:29:42.000+0000" }, { "id": "453072", "author": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "body": "Mhhh, but what to do with the webview? I want to handle the URL with an external browser and return to the app, so I feel this could lead into a memory leak.\r\n\r\n*EDIT*: Manually disabling the native property doesn't help btw. I compiled a new SDK and it works with the first click and fails for all additional clicks.", "updateAuthor": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "created": "2019-12-06T20:56:15.000+0000", "updated": "2019-12-06T21:03:38.000+0000" } ], "maxResults": 4, "total": 4, "startAt": 0 } } }