在外部浏览器中从blackberry10与cordova打开链接 [英] Open link in external browser from blackberry10 with cordova

查看:194
本文介绍了在外部浏览器中从blackberry10与cordova打开链接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试从我的blackberry10应用程序打开本机浏览器或其他外部浏览器中的链接,但我只能打开一个在应用程序的浏览器。请帮助我。

解决方案

看起来您使用的是org.apache.cordova.inappbrowser插件,默认操作是在childBrowser窗口中打开一个新页面。
如果要在系统浏览器中打开它,您有两个选项:



选项1:在调用中使用_system目标。 >

您的代码将如下所示:

  var ref = window.open http://www.google.com','_system'); 

选项2:使用BlackBerry特定的invokeapi。
为了这样做,您需要先安装invoke插件。

  cordova插件add com.blackberry.invoke 

现在你可以有一个函数,使用org.apache.cordova.device插件:

  function openBlackBerryBrowser(url){

function onInvokeSuccess(){
alert Invocation success!);
}

函数onInvokeError(错误){
alert(调用失败,错误:+错误);
}

blackberry.invoke.invoke({
target:sys.browser,
uri:url
},onInvokeSuccess,onInvokeError);
}

if(window.device.platform.toLowerCase()。indexOf('blackberry')> -1){
openBlackBerryBrowser('http: google.com');
} else {
var ref = window.open('http://www.google.com','_system');
}



如果您注意到我将目标属性设置为sys.browser这是默认的系统浏览器。如果用户安装了不同的浏览器,您只需指定不同的类似com.myapp.mybrowser。


I am trying to open a link in the native browser or other external browser from my blackberry10 app, but I can only get it to open an in app browser. Please help me.

解决方案

It seems that you are using the org.apache.cordova.inappbrowser plugin which is cross compatible but the default action is to open a new page in the childBrowser window. If you want to open it in the system browser you have two options:

OPTION 1: use the "_system" target in your call.

Your code will look like this

var ref = window.open('http://www.google.com', '_system');

OPTION 2: use the BlackBerry specific "invoke" api. In order to do so you need to first install the invoke plugin

cordova plugin add com.blackberry.invoke

Now you can have a function that (using the org.apache.cordova.device plugin) looks like this:

function openBlackBerryBrowser(url) {

    function onInvokeSuccess() {
        alert("Invocation successful!");
    }

    function onInvokeError(error) {
       alert("Invocation failed, error: " + error);
    }

    blackberry.invoke.invoke({
        target: "sys.browser",
        uri: url
    }, onInvokeSuccess, onInvokeError);
}

if(window.device.platform.toLowerCase().indexOf('blackberry') > -1) {
    openBlackBerryBrowser('http://www.google.com');
} else {
    var ref = window.open('http://www.google.com', '_system');
}

if you notice I'm setting the target attribute to "sys.browser" which is the default system browser. If the user has different browsers installed you could just specify something different like "com.myapp.mybrowser".

这篇关于在外部浏览器中从blackberry10与cordova打开链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆