androidcordovacordova-2.0.0inappbrowser

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


I'm using the cordova InAppBrowser to display content from an external site in my app. When I open the browser on an iPhone, there are some buttons at the bottom of the InAppBrowser for closing it or navigating back and forth. The InAppBrowser on an Android device has no such buttons and has no obvious way for the user to close the browser.

I know how to programmatically close the InAppBrowser, but how can the user close it when using an Android device?

I know the user can hit the hardware back button to close the browser, but (1) that's not intuitive - the back button typically means "go back a page", and (2) I'd eventually like to change the behavior of the back button to go back a page within the site that is displaying inside the InAppBrowser, rather than close the browser.


Solution

  • Adding "location=yes" to the end of your call will place an address bar and DONE button at the top of the window on Android. (It appears at the bottom of the window in iOS). Clicking Done closes the window.

    var ref = window.open('http://apache.org', '_blank', 'location=yes');