[ https://issues.apache.org/jira/browse/CB-14188?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16547956#comment-16547956 ]
ASF GitHub Bot commented on CB-14188: ------------------------------------- wvengen edited a comment on issue #276: CB-14188: add beforeload event, catching navigation before it happens URL: https://github.com/apache/cordova-plugin-inappbrowser/pull/276#issuecomment-405965660 Thanks a lot for your review and comments, @brodybits. I agree that the current approach is not ideal, and have struggled with how to add the callback. Indeed, a synchronous callback would be the best option, that would first need some research to whether Android's and iOS's WebView implementation allow this to take a little time (because it involves a Javascript invocation). If this is not possible (or if this is ported to a platform requiring near-immediate return from its do-I-need-to-load-this-URL-function), for Cordova users it can still be a synchronous function, with the help of a workaround similar to what happens now, but without the concurrency issue you mentioned (I have an idea to do this using a custom URL scheme). Interesting you mention the `beforeunload` event, that would be familiar to many. In our case, the confirm dialog would not be shown. It also makes sense to skip this on first page load, as that is always controlled by the inAppBrowser-invoking code. I'll delve into this. Since I'll be on holiday for about two weeks, it may take a little time. ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > Callback to decide whether to open link or not. > ----------------------------------------------- > > Key: CB-14188 > URL: https://issues.apache.org/jira/browse/CB-14188 > Project: Apache Cordova > Issue Type: New Feature > Components: cordova-plugin-inappbrowser > Affects Versions: 3.0.0 > Reporter: wvengen > Priority: Major > > Several times I've found myself wanting to tell inAppBrowser whether it can > open a link in the embedded webview or using the system web browser. It would > be great if there's a callback _before_ loading a page (loadstart is too late > there), where I can tell inAppBrowser to load the page or not. > CB-14013 introduced AllowedSchemes, but excluded the use of http and https. > -It would be useful to allow intercepting http and https links, e.g. to > decide whether to open the link in the system web browser or not.- At first I > thought this mechanism could be used, but because of the asynchronous nature > of Cordova callbacks, this didn't work out, and I added a beforeload > callback. See comment for an example. > I've submitted a PR -(my approach would be to generate a regexp based on > AllowedSchemes and match the URL on that, instead of the current if logic)-. -- This message was sent by Atlassian JIRA (v7.6.3#76005) --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@cordova.apache.org For additional commands, e-mail: issues-h...@cordova.apache.org