1

I am building an ionic app and using the cordova inappbrowser plugin. From within my App I need to open an external web page using the inappbrowser. On this web page I need to provide a custom close button to the user, which closes the browser window when clicked.

I have looked at a number of existing threads such as Phonegap build - Open external page in InAppBrowser or childbrowser with no toolbar and close it?

window.close equivalent in Phonegap with InAppBrowser

How can I get the cordova InAppBrowser to provide a way for the user to close the browser when using an Android device?

While I am able to get inappbrowser window to open my url using

window.open('http://myurl.com', '_blank', 'location=no').

I am not able to close the inappbrowser window using the approaches suggested.

When I use

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

However the link on the webpage <a href="/mobile/close">Close</a>

does not close the inappbrowser window. On clicking it shows a 404 not found error.

I have also tried impossible to close inAppBrowser window [Solved] But no success. Please help. Thanks

Community
  • 1
  • 1
Anurag
  • 84
  • 3
  • 17
  • check out this link - http://stackoverflow.com/questions/38592848/how-to-quit-the-application-from-my-android-device-back-button-in-cordova/38604023#38604023 this closes inapp browser on click of back button. Hope it helps.keep me posted – Gandhi Aug 06 '16 at 02:55
  • Thanks for your suggestion. Unfortunately my requirement is such that I need to create a button to close the browser and cannot depend on the back button. – Anurag Aug 09 '16 at 08:07
  • Then you gotta checkout themeable browser - https://github.com/initialxy/cordova-plugin-themeablebrowser – Gandhi Aug 09 '16 at 12:08

0 Answers0