[
https://issues.apache.org/jira/browse/CB-13198?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17141106#comment-17141106
]
Pat commented on CB-13198:
--------------------------
Same issue, today coincidentally. All events on the inappbrowser stop firing
after opening system browser. Reattaching same events to whatever is returned
from window.open _system call seems to resolve. Appears to be affecting Android
only. Thanks Laxman you saved me hours of debugging probably
> InAppBrowser doesnot disptach events after system browser is open using
> cordova.InAppBrowser.open(url, '_system')
> -----------------------------------------------------------------------------------------------------------------
>
> Key: CB-13198
> URL: https://issues.apache.org/jira/browse/CB-13198
> Project: Apache Cordova
> Issue Type: Bug
> Components: cordova-plugin-inappbrowser
> Reporter: Laxman
> Priority: Major
> Labels: documentation, inAppBrowser, system-browser
>
> The InAppBrowser instance does not automatically dispatch the events after
> the system browser is opened via InAppBrowser. Please follow the generic code
> below:
> {code:java}
> //example 1 : bug with cordova.InAppBrowser.open(url, '_system');
> //event hander for inAppBrowser
> function inAppBrowserEventHandler(event){
> //process few logic with the event parameter
> //and if conditions met lets open it on system browser
> var url = 'https://cordova.apache.org/';
> //open the url in system browser
> var _inAppBrowserSystem = cordova.InAppBrowser.open(url, '_system');
> }
> //open the link in inside the iAB without
> var _inAppBrowser = cordova.InAppBrowser.open(url, '_blank');
> _inAppBrowser.addEventListener('loadstop', inAppBrowserEventHandler);
> {code}
> The _inAppBrowser instance works fine for the first time. But as soon as the
> system browser is opened, the event 'for eg. loadstop' does not fire
> automatically. This bug/issue appears only when system browser is open. for
> eg, the following code works perfectly.
> {code:java}
> //example 2 : no bug without cordova.InAppBrowser.open(url, '_system');
> //event hander for inAppBrowser
> function inAppBrowserEventHandler(event){
> //process few logic with the event parameter
> //and if conditions met lets open it on system browser
> var url = 'https://cordova.apache.org/';
> //log the url in the console instead of browser
> console.log('open this url in the system browser ' + url)
> }
> //open the link in inside the iAB without
> var _inAppBrowser = cordova.InAppBrowser.open(url, '_blank');
> _inAppBrowser.addEventListener('loadstop', inAppBrowserEventHandler);
> {code}
> It seems the new '_inAppBrowserSystem' instance somehow interrupts the event
> dispatcher for the '_inAppBrowser' instance. I found that if the
> _inAppBrowserSystem is assign the same eventHandler, then _inAppBrowser
> starts to dispatch the event. The following code helped me solve the problem
> but this should still be registered as a bug.
> {code:java}
> //example 3 : hack/solution with cordova.InAppBrowser.open(url, '_system');
> //event hander for inAppBrowser
> function inAppBrowserEventHandler(event){
> //process few logic with the event parameter
> //and if conditions met lets open it on system browser
> var url = 'https://cordova.apache.org/';
> //open the url in system browser
> var _inAppBrowserSystem = cordova.InAppBrowser.open(url, '_system');
> //for somereason, after assigning the same event handler to the
> _inAppBrowserSystem, the event dispatcher continues to work
> _inAppBrowserSystem.addEventListener('loadstop', inAppBrowserEventHandler);
> }
> //open the link in inside the iAB without
> var _inAppBrowser = cordova.InAppBrowser.open(url, '_blank');
> _inAppBrowser.addEventListener('loadstop', inAppBrowserEventHandler);
> {code}
> I have the solution for now, but I still register this as a bug as the event
> dispatcher is not consistent. For instance, the code in 'example 1' should
> work as in 'example 2'. If there is not a quick fix, I hope at least the
> documentation get updated with this hack.
> Thx
> Laxman
--
This message was sent by Atlassian Jira
(v8.3.4#803005)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]