科尔多瓦:使用Google Chrome浏览器打开链接 [英] Cordova : Open a link using Google Chrome
问题描述
我想从我的Cordova应用程序中使用Google Chrome(而不是其他浏览器)打开一个链接.我尝试了几种解决方案,但没有任何效果.
I would like to open a link using Google Chrome (not another browser) from my Cordova application. I tried several solutions but nothing works.
首先,我尝试创建到googlechrome://
的链接(使用HTML <a>
标记).它会打开谷歌浏览器,但我无法选择要打开的URL.
First, I tried to create a link to googlechrome://
(using a HTML <a>
tag). It opens Google Chrome, but I can't choose what URL to open.
然后,我尝试创建到intent://my.url.com/#Intent;scheme=https;package=com.android.chrome;end
的链接.当我从浏览器(例如Firefox或Google Chrome)中打开该链接时,该链接有效,但当我从Cordova应用程序中打开该链接时,该链接不起作用.
Then, I tried to create a link to intent://my.url.com/#Intent;scheme=https;package=com.android.chrome;end
. This link works when I open it from a browser (like Firefox or Google Chrome), but it doesn't work when I open it from my Cordova app.
我还尝试使用 cordova-webintent 插件,例如:
I also tried to use the cordova-webintent plugin, like that :
window.plugins.webintent.startActivity(
{
action: window.plugins.webintent.ACTION_VIEW,
url: 'intent://my.url.com/#Intent;scheme=https;package=com.android.chrome;end'
},
function() {
alert(url);
},
function(){
alert('Failed to open URL via Android Intent');
}
);
但是我收到一个无法通过Android Intent打开URL" 错误.
我该怎么办?
PS:我在config.xml文件中写了<allow-intent href="*" />
.
PS : I wrote <allow-intent href="*" />
in my config.xml file.
推荐答案
我终于找到了解决方案.我只需要创建一个像这样的链接:
I finally found the solution. I just had to create a link like this one :
<a href="googlechrome://navigate?url=https://my.url.com/"></a>
这篇关于科尔多瓦:使用Google Chrome浏览器打开链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!