cordova-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Erik Jan de Wit (JIRA)" <j...@apache.org>
Subject [jira] [Comment Edited] (CB-6230) InAppBrowser closes after opening, instead of before
Date Thu, 03 Jul 2014 12:54:25 GMT

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

Erik Jan de Wit edited comment on CB-6230 at 7/3/14 12:53 PM:
--------------------------------------------------------------

It's because all of these functions are async, but there is an event that gets called when
the close is done. So you could add a listener like this:

{code}
if (window.myWindow) {
    window.myWindow.addEventListener('exit', function() {
        window.myWindow = window.open('http://www.google.com', "_blank");
    });
    window.myWindow.close();
} else {
    window.myWindow = window.open('http://www.google.com', "_blank");
}
{code}


was (Author: edewit):
It's because all of these functions are async, but there is an event that get's called when
the close is done. So you could add a listener like this:

{code}
            if (window.myWindow) {
                window.myWindow.addEventListener('exit', function() {
                    window.myWindow = window.open('http://www.google.com', "_blank");
                });
                window.myWindow.close();
            } else {
                window.myWindow = window.open('http://www.google.com', "_blank");
            }
{code}

> InAppBrowser closes after opening, instead of before
> ----------------------------------------------------
>
>                 Key: CB-6230
>                 URL: https://issues.apache.org/jira/browse/CB-6230
>             Project: Apache Cordova
>          Issue Type: Bug
>          Components: Android, Plugin InAppBrowser
>    Affects Versions: 3.4.0, 3.5.0
>            Reporter: Jacob Weber
>
> In Cordova 3.4, with InAppBrowser 0.3.3, create a new project using the CLI. In www/js/index.js,
make the following change:
> {noformat}
>     onDeviceReady: function() {
>         app.receivedEvent('deviceready');
>         document.addEventListener('click', function() {
>             if (window.myWindow) window.myWindow.close();
>     	    window.myWindow = window.open('http://www.google.com', "_blank");
>     	});
>     },
> {noformat}
> Tap the page once, and a browser will appear. Close the browser. Then tap the app again.
This time the browser will appear for a split second, then close right away. The close() call
seems to be happening after the subsequent open() call, instead of before it.
> This was working in 3.3, with InAppBrowser 0.2.5.



--
This message was sent by Atlassian JIRA
(v6.2#6252)

Mime
View raw message