[ 
https://issues.apache.org/jira/browse/CB-14188?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16544993#comment-16544993
 ] 

wvengen edited comment on CB-14188 at 7/16/18 9:30 AM:
-------------------------------------------------------

Also implemented on iOS (with behaviour similar to Android, where embedded 
iframes are always allowed).

The feature would be used like this (sorry, no code-formatting because renderer 
breaks):

_app = cordova.InAppBrowser.open(url, "_blank", "beforeload=yes")_
_app.addEventListener("beforeload", function(e, cb) {_
  _if (e.url.startsWith("https://example.com/";)) {_
    _cb(e.url); // Tell inAppBrowser to open the URL indeed._
  _} else {_
    _alert("Opened external URL: " + e.url);_
  _}_
_}, false);_

Note that one can customize the opened URL (e.g. to add a query parameter).


was (Author: wvengen):
Also implemented on iOS (with behaviour similar to Android, where embedded 
iframes are always allowed).

The feature would be used like this:

{{  app = cordova.InAppBrowser.open(url, "_blank", "beforeload=yes")}}
 {{ app.addEventListener("beforeload", function(e, cb) { }}
 {{   if (e.url.startsWith("https://example.com/";)) { }}
 {{     cb(e.url); // Tell inAppBrowser to open the URL indeed.}}
 {{   } else { }}
 {{     alert("Opened external URL: " + e.url); }}
 {{   } }}
 {{ }, false);}}

Note that one can customize the opened URL (e.g. to add a query parameter).

> Allow http and https for AllowedSchemes
> ---------------------------------------
>
>                 Key: CB-14188
>                 URL: https://issues.apache.org/jira/browse/CB-14188
>             Project: Apache Cordova
>          Issue Type: Improvement
>          Components: cordova-plugin-inappbrowser
>    Affects Versions: 3.0.0
>            Reporter: wvengen
>            Priority: Major
>
> 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.
> I'd be happy to submit 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: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to