Cordova 3.0 - Open link in external browser in iOS

前端 未结 2 706
挽巷
挽巷 2021-02-05 13:56

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

People have suggested using window.open( url, \"_system\" ) but this does

相关标签:
2条回答
  • 2021-02-05 14:45

    install InAppBrowser plugin:

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

    and execute the plugin in your .js file:

    //exec(successCallback, errorCallback, pluginName, pluginMethod, params)
    cordova.exec(null, null, "InAppBrowser", "open", [url, "_system"]);
    
    0 讨论(0)
  • 2021-02-05 14:46

    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

    From the Docs for 3.0:

    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 (in config.xml)

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

    I just tested this and it works.

    0 讨论(0)
提交回复
热议问题