我对xcode是个新手,如果我使用inappbrowser方法在phonegap中实现了一个外部url,该url不会加载,我会得到一个白屏,在底部会有一条信息显示为load error和load stop message not window.open()。
我在config.xml中包含了<plugin name="InAppBrowser" value="CDVInAppBrowser" />,并使用了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);
});
}发布于 2014-10-11 21:08:55
修改res/xml/config.xml中的访问源值,如下所示。
<access origin="*" subdomains="true" />
Apache Cordova中的域白名单是一种安全模型,用于控制对外部域的访问,例如http://google.com。默认安全策略是阻止所有网络访问。这就是InAppBrowser中没有加载外部url的原因。
有关详细信息,请参阅以下链接。
http://docs.phonegap.com/en/2.3.0/guide_whitelist_index.md.html#Domain%20Whitelist%20Guide
https://stackoverflow.com/questions/26313173
复制相似问题