zeroonea
Posts: 0
Joined: Sun Jun 03, 2012 8:29 am

window.open problem

When I using window.open('[url=http://rere.vn')]http://rere.vn')[/url], it call a stock browser of my android fone. It is not display the site embedded in app. Is it normal? How to open an url inside app. I don't want open an url in other browser.

maxkatz
Posts: 0
Joined: Fri Aug 13, 2010 3:24 pm

window.open problem

To open a page within your app, use PhoneGap's child browser:

code
var childBrowser = ChildBrowser.install();
window.plugins.childBrowser.showWebPage('http://google.com');
/code

Michael495572
Posts: 0
Joined: Fri Aug 10, 2012 5:22 am

window.open problem

Hi Max.

I can't seem to get the JS you posted to work. If I include the var childBrowser line in an event on load of my screen, the app just hangs both in the web preview and ios preview.

maxkatz
Posts: 0
Joined: Fri Aug 13, 2010 3:24 pm

window.open problem

Do it on button click.

Toblerone
Posts: 0
Joined: Wed Aug 07, 2013 5:08 pm

window.open problem

This code does not work, it does nothing on button click

Kateryna Grynko
Posts: 0
Joined: Thu Nov 15, 2012 9:13 am

window.open problem

Hi,

ChildBrowser is a PhoneGap plug-in that works for installed ipa/apk only, but not on browser.

Create new JavaScript asset with the following code:
codefunction myNavigate(url) {
var cb;
if (window.plugins) {
cb = window.plugins.childBrowser;
}
if (cb != null) {
cb.showWebPage(url);
} else {
window.open(url);
};
}/code
On Click event instead of code:
codevar childBrowser = ChildBrowser.install();
window.plugins.childBrowser.showWebPage('http://...');/code
run:
codemyNavigate('http://...');/code

Return to “Issues”