Cordova 3.0 - 在iOS中的外部浏览器中打开链接 [英] Cordova 3.0 - Open link in external browser in iOS

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

问题描述

当在iOS上使用Cordova 3.0时,如何在设备本机浏览器中打开链接?

How do you open links in the devices native browser when using Cordova 3.0 on iOS?

人们建议使用 window.open ,_system),但在Cordova 3.0中无效。

People have suggested using window.open( url, "_system" ) but this does not work in Cordova 3.0.

我的尝试 b
$ b

My Attempt

if( navigator.app ) // Android
    navigator.app.loadUrl( url, {openExternal:true} )
else // iOS and others
    window.open( url, "_system" ) // opens in the app, not in safari

有没有人知道与Cordova 3.0配合使用的解决方案?

感谢

Does anyone know of a solution that works with Cordova 3.0?
Thanks

推荐答案

:让 window.open('somelink','_system')工作你现在需要一个设备级插件,inAppBrowser。以下是Cordova 3.0的安装说明

NOTE: to make window.open('somelink', '_system') to work you now need a device-level plugin, the inAppBrowser. Here are the installing instructions as of Cordova 3.0

从Docs for 3.0:

From the Docs for 3.0:

Cordova实现了作为插件的设备级API。使用命令行界面中描述的CLI的插件命令为项目添加或删除此功能:

As of version 3.0, Cordova implements device-level APIs as plugins. Use the CLI's plugin command, described in The Command-line Interface, to add or remove this feature for a project:

$ cordova plugin add https://git-wip-us.apache.org/repos/asf/cordova-plugin-inappbrowser.git
$ cordova plugin rm org.apache.cordova.core.inappbrowser

这些命令适用于所有目标平台,但修改以下平台特定的配置设置:

These commands apply to all targeted platforms, but modify the platform-specific configuration settings described below:

iOS(在config.xml中)

iOS (in config.xml)

<feature name="InAppBrowser">
    <param name="ios-package" value="CDVInAppBrowser" />
</feature>

我只是测试了这个,它工作。

I just tested this and it works.

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

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