外部网址不在inappbrowser中工作

时间:2014-10-11 09:31:28

标签: javascript ios xcode cordova

我是xcode的新手, 如果我使用inappbrowser方法在phonegap中实现外部网址是window.open() 网址没有加载,我得到一个白色的屏幕,在底部有一条消息显示为加载错误,也没有加载停止消息。
我加入了<plugin name="InAppBrowser" value="CDVInAppBrowser" /> 在config.xml中我使用了cordova2.3.0

function loadURL(url){
    var ref = window.open('url', '_blank','location=yes');
    ref.addEventListener('loadstart', function(event) { 
        alert('start: ' + event.url);
        window.locaion.href='url';
    });
    ref.addEventListener('loadstop', function(event) { 
        alert("open web site"+event.type); 
    });
    ref.addEventListener('exit', function(event) { 
        alert(event.type); 
    });
}

1 个答案:

答案 0 :(得分:0)

在res / xml / config.xml中修改访问源值,如下所示。

<access origin="*" subdomains="true" />

Apache Cordova中的域白名单是一种安全模型,用于控制对外部域的访问,例如http://google.com。默认安全策略是阻止所有网络访问。这就是外部URL未在InAppBrowser中加载的原因。

有关详细信息,请参阅以下链接。

http://docs.phonegap.com/en/2.3.0/guide_whitelist_index.md.html#Domain%20Whitelist%20Guide

相关问题