简体   繁体   English

外部网址在inappbrowser中不起作用

[英]External url not working in inappbrowser

I am new to xcode, if I implement an external url in phonegap using inappbrowser method is window.open() the url is not loading, I get a white screen and at bottom a message is shown as load error and also load stop message not get. 我是xcode的新手,如果我使用inappbrowser方法在phonegap中实现一个外部URL是window.open()该URL未加载,我得到一个白屏,并且在底部显示一条消息,显示为加载错误,并且未加载停止消息得到。
I included <plugin name="InAppBrowser" value="CDVInAppBrowser" /> in config.xml and I used cordova2.3.0 我在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); 
    });
}

Modify the access origin value as below in res/xml/config.xml. 如下修改res / xml / config.xml中的访问源值。

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

Domain whitelisting in Apache Cordova is a security model that controls access to outside domains, such as http://google.com . Apache Cordova中的域白名单是一种安全模型,用于控制对外部域(例如http://google.com)的访问 The default security policy is to block all network access. 默认的安全策略是阻止所有网络访问。 This is the reason external url are not loading in InAppBrowser. 这是外部URL未加载到InAppBrowser中的原因。

Refer to the following link for more information. 有关更多信息,请参考以下链接。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM