PhoneGap Build:如何在Android设备浏览器中打开外部URL?

Joa*_*oan 19 javascript android cordova phonegap-build

外部URL不会在我的PhoneGap Android应用程序的系统浏览器中打开.我正在使用PhoneGap Build 2.3.0.

根据Cordova文档,我使用了目标'_system':

window.open('http://www.myurl.nl', '_system');
Run Code Online (Sandbox Code Playgroud)

在我的config.xml中,我有:

<plugin name="InAppBrowser" value="org.apache.cordova.InAppBrowser" />
<access origin="*" browserOnly="true" />
Run Code Online (Sandbox Code Playgroud)

但仍然在我的应用程序webview中打开链接.

怎么解决这个?

Joa*_*oan 15

当你想继续使用PhoneGap Build时,这不是答案,但我通过在我的机器上为Cordova(PhoneGap)设置开发环境并在本地编译应用程序来解决问题.在Cordova 2.5.0 window.open('http://www.myurl.nl', '_system');工作正常,它将在系统的浏览器中打开链接.

所以我的建议是停止使用PhoneGap Build并开始在本地编译你的应用程序.以下是如何为Cordova >>设置开发环境


Ata*_*CSE 14

迟到的答案,但可能会有所帮助.

navigator.app.loadUrl('https://google.com/', { openExternal:true });
Run Code Online (Sandbox Code Playgroud)

科尔多瓦3.3.1


boo*_*dle 7

这个问题现在有点老了,但我觉得值得更新.当与2.9.0一起使用时,现在可以正常使用PhoneGap Build.

我已经在Android 4.3和iOS 6.1.3上编译和测试了它.我的应用程序中没有InAppBrowser插件,因为打开应用程序中的页面,而不是让本机浏览器打开它们,我只有以下访问标记:

<access origin="http://127.0.0.1*"/>
<access origin="http://phonegap.com" subdomains="true" />
Run Code Online (Sandbox Code Playgroud)


Geo*_*lou 7

这对我有用.Phonegap 3.1.0.

HTML代码:

<a id="ext-link" href="#">Google it</a>
Run Code Online (Sandbox Code Playgroud)

要么

<button id="ext-link" href="#">Google it</button>
Run Code Online (Sandbox Code Playgroud)

Javascript(使用jQuery + cordova):

$("#ext-link").on("click"), function() {
    if (typeof navigator !== "undefined" && navigator.app) {
        // Mobile device.
        navigator.app.loadUrl('http://www.google.com/', {openExternal: true});
    } else {
        // Possible web browser
        window.open("http://www.google.com/", "_blank");
    }
});
Run Code Online (Sandbox Code Playgroud)

希望有所帮助.