Otávio Barreto
Otávio Barreto

Reputation: 1558

Phonegap inappbrowser do not load, shows blank page

This is phonegap main file www/index.html I want to load my site like a native app, the script:

//var ref = cordova.InAppBrowser.open('http://website.com/page/index.php', '_self', 'location=no');
 document.addEventListener("deviceready", function(){
       window.open = cordova.InAppBrowser.open('http://website.com/page/index.php', '_self', 'location=no');
 },true);

</script>

my phonegap config.xml file

<plugin name="cordova-plugin-inappbrowser" source="npm" spec="~1.3.0" />
<content src="index.html" />
<access origin="*" />
<allow-intent href="http://*/*" />
<allow-intent href="https://*/*" />
<allow-intent href="tel:*" />
<allow-intent href="sms:*" />
<allow-intent href="mailto:*" />
<allow-intent href="geo:*" />
<allow-intent href="itms:*" />
<allow-intent href="itms-apps:*" />

also my website has enable in all pages

header('Access-Control-Allow-Origin: *');

the website in the script is not my website at all because I am running it on localhost, I tested the website in same network with phone browser and it works just fine, but when I try to load via phone gap app it shows blank page

Upvotes: 0

Views: 407

Answers (1)

terrencep
terrencep

Reputation: 673

your code is changing the prototype default for windows.open(), not actually opening anything;

what you need is:

window.open = cordova.InAppBrowser.open;//change default prototype to cordova
var ref = cordova.InAppBrowser.open(url, target, options);//inappbrwoser reference

then you can do ref.close(),show(),hide() etc.

you can also addEventListener

Upvotes: 1

Related Questions