window.close equivalent in Phonegap with InAppBrowser

I use a workaround…
Since the inAppBrowser can be closed only with the back button or trough javascript. I display a close button from serverside that will change the current url firing also the event ‘loadstop’ letting to use the .close() method, in this way only the child browser will be closed, your app will remain in the same state.

For example my server display a webpage with a close button, something like this:

<a href="">Close</a>

in my client side javascript (the Phonegap app):

var ref =, '_blank', options);
ref.addEventListener('loadstop', function(event) {        
    if (event.url.match("mobile/close")) {

Leave a Comment