Question

In my phonegap Android project I want to open external files in popup.Using window.open files are get opened but my issue is that I need a close button in the opened window,so that user can close the window and return back to app.

Was it helpful?

Solution

Use cordova InAppBrowser

window.open('http://www.google.co.in','_blank','location=yes','closebuttoncaption=CLOSE');

Before using inappbrowser you must install the plugin to your project.

To add inappbrowser to project by commanline

$ phonegap local plugin add https://git-wip-us.apache.org/repos/asf/cordova-plugin-inappbrowser.git

UPDATE

In android InAppBrowser wont shows Done/Close button without the location toolbar, to enable the toolbar put 'location=yes' in window.open

There is another way, if you dont want to show the location/url

just comment these lines of codes in InAppBrowser.java class

 toolbar.addView(actionButtonContainer);
 toolbar.addView(edittext);
 toolbar.addView(close);

 // Don't add the toolbar if its been disabled
 if (getShowLocationBar()) {
     // Add our toolbar to our main view/layout
     main.addView(toolbar);
 }

and put this

 toolbar.addView(actionButtonContainer);
 if (getShowLocationBar()) {
     toolbar.addView(edittext);
 }
 toolbar.addView(close);

 // Add our toolbar to our main view/layout
 main.addView(toolbar);

This will shows a Close button.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top