GitToTheHub opened a new pull request, #1143: URL: https://github.com/apache/cordova-plugin-inappbrowser/pull/1143
<!-- Please make sure the checklist boxes are all checked before submitting the PR. The checklist is intended as a quick reference, for complete details please see our Contributor Guidelines: http://cordova.apache.org/contribute/contribute_guidelines.html Thanks! --> ### Platforms affected - iOS ### Motivation and Context <!-- Why is this change required? What problem does it solve? --> <!-- If it fixes an open issue, please link to the issue here. --> I want to open a link in the external browser, which is clicked in the in-app browser, by listening to the event `beforeload` and open the link by `cordova.InAppBrowser.open(externalUrl, _system)`. After doing that, the `beforeload` event is not triggered anymore because the in-app browser reference has changed by `open(externalUrl, _system)`. Since `_system` is used and the in-app browser just forwards the call, it's is not necessary to change the reference. Also the documentation already states that the reference to the `InAppBrowser` window is set, when the target is set to `'_blank'` only. On Android, non-whitelisted URLs also fall back to the `InAppBrowser` when the target is set to `'_self'`, which is not the case on iOS. This case was updated in the README. ### Testing <!-- Please describe in detail how you tested your changes. --> Tested successfully in an App with the event `beforeload` and opening a specific link external: ```js const inAppBrowserRef = cordova.InAppBrowser.open(url, "_blank", "beforeload=yes"); inAppBrowserRef.addEventListener("beforeload", (inAppBrowserEvent, callback) => { // Open clicked link external if (inAppBrowserEvent.url == "https://myExternalUrl.com") { cordova.InAppBrowser.open(inAppBrowserEvent.url, "_system"); } else { // Load URL in in-app browser callback(inAppBrowserEvent.url); } }); ``` On Android only the first page load in the in-app browser will fire `beforeload`. After this the event will not be fired again, e.g. when a link is clicked, which seems to be a bug on Android and has nothing to do with this PR. ### Checklist - [ ] I've run the tests to see all new and existing tests pass - [ ] I added automated test coverage as appropriate for this change - [ ] Commit is prefixed with `(platform)` if this change only applies to one platform (e.g. `(android)`) - [ ] If this Pull Request resolves an issue, I linked to the issue in the text above (and used the correct [keyword to close issues using keywords](https://help.github.com/articles/closing-issues-using-keywords/)) - [ ] I've updated the documentation if necessary -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
