Phonegap 3.0 InAppBrowser - Provides no way for user to close

user2883611 picture user2883611 · Oct 15, 2013 · Viewed 8.7k times · Source

I had inApBrowser working in my app just fine... however, I upgraded some things and now it opens the URL without any way of closing it. You have to kill the app.

I have tried many variations of this: window.open('http://cnn.com','_blank','location=yes,toolbar=yes');

myconfig.xml has:

<feature name="InAppBrowser">
    <param name="ios-package" value="CDVInAppBrowser" />
</feature>

I get no errors... the page opens... but there is no way to close and return to the app. I have seen a lot of folks putting solutions for URL recognition and making the window close... but I need the childBrowser plugin method... where the user can close the window when he/she is finished viewing the page.

Phonegap 3.0 - JqueryMobile 1.2 - IOS 7.0.2 - xCode 5.0 -

Any help would be greatly appreciated!

Answer

wicketyjarjar picture wicketyjarjar · Oct 18, 2013

Your syntax looks okay, but give these code snippets a try:

Pure JavaScript:

var ref = window.open('http://cnn.com', '_blank', 'location=yes,toolbar=yes');

HTML + JavaScript:

<a href="#" onclick="var ref = window.open('http://cnn.com', '_blank', 'location=yes,toolbar=yes');">CNN Link</a>

Also, check that you have correctly installed the InAppBrowser plugin (PhoneGap/Cordova 3.0+ need it to be installed separately via the command line). Your config.xml file looks correct, but just make sure that the rest of the plugin is installed properly.

You can use the following commands to list all the installed plugins in your project...

Using Cordova: cordova plugins

Using PhoneGap: phonegap local plugin list

You can also just go to your Desktop, navigate to the 'plugins' folder within your project and check that there is a folder named 'org.apache.cordova.inappbrowser' or 'org.apache.cordova.core.inappbrowser' inside.

To install the InAppBrowser plugin (if necessary)...

Using Cordova: cordova plugin add org.apache.cordova.inappbrowser

Using PhoneGap: phonegap local plugin add org.apache.cordova.inappbrowser

From your description, it sounds like your page is opening within the app's webview, instead of the InAppBrowser window. This is the behaviour you would normally get if you used '_self' instead of '_blank'. Hopefully something here will help fix it.