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

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-409489649
 
 
   Reading up on HTML's `beforeunload` event, I do see `preventDefault()`, e.g. 
on [MDN](https://developer.mozilla.org/en-US/docs/Web/Events/beforeunload), 
[W3C HTML 5.0](https://www.w3.org/TR/html50/browsers.html#unloading-documents) 
(suggesting `e.returnValue`) and 
[WHATWG](https://html.spec.whatwg.org/#prompt-to-unload-a-document) (preferring 
`e.preventDefault()`).
   
   I would suggest to adopt `e.returnValue` and `e.preventDefault()` in 
InAppBrowser's new `beforeunload` event. This is in-line with current 
standards, allows using the existing event handling infrastructure, and by 
updating the event this will also work with multiple event handlers. It does 
require some changes to the event object passed on to the handlers (so that 
returnValue can be reported back, and `e.preventDefault()` is available).

----------------------------------------------------------------
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:
[email protected]


> 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: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to