【问题标题】:Phonegap inappbrowser do not load, shows blank pagePhonegap inappbrowser 不加载,显示空白页
【发布时间】:2019-08-18 03:19:51
【问题描述】:

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

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

我的phonegap config.xml文件

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

我的网站也已在所有页面中启用

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

脚本中的网站根本不是我的网站,因为我在本地主机上运行它,我用手机浏览器在同一个网络中测试了网站,它工作得很好,但是当我尝试通过手机间隙应用程序加载时它显示空白页

【问题讨论】:

    标签: javascript cordova cordova-plugins phonegap inappbrowser


    【解决方案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

    【讨论】:

    • 谢谢,我已经使用 iframe 解决了,但也很好解决
    猜你喜欢
    • 2016-05-20
    • 1970-01-01
    • 2012-03-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-06-05
    相关资源
    最近更新 更多