Phonegap inappbrowser无法加载,显示空白页

时间:2019-08-18 03:19:51

标签: javascript cordova cordova-plugins phonegap inappbrowser

这是phonegap主文件 www / index.html ,我想像本地应用一样加载我的网站,脚本是:

ServiceRequired

我的phonegap config.xml 文件

//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>

我的网站还在所有页面中启用了

<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:*" />

脚本中的网站根本不是我的网站,因为我在本地主机上运行它,我使用电话浏览器在同一网络中测试了该网站,并且效果很好,但是当我尝试通过手机缺口应用程序加载时,它显示空白页

1 个答案:

答案 0 :(得分:1)

您的代码正在更改windows.open()的原型默认值,实际上并未打开任何内容;

您需要的是:

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

然后您可以进行ref.close(), show(),hide()等。

您还可以添加EventListener