【问题标题】:Links to open in Safari browser, using Phonegap 3.3使用 Phonegap 3.3 在 Safari 浏览器中打开的链接
【发布时间】:2014-05-29 17:30:26
【问题描述】:

我在 Phonegap Build 3.3 中使用纯 HTML、CSS 和 JS 构建了一个应用程序。我想包含一些指向网站的链接,我想在 Safari 而不是应用内浏览器中打开这些链接。任何人都可以解释一下吗?我已经尝试了所有使用 _system 作为目标等的明显 JS。

Config.xml 如下:

<?xml version="1.0" encoding="UTF-8" ?>
<widget 
    xmlns = "http://www.w3.org/ns/widgets"
    xmlns:gap   = "http://phonegap.com/ns/1.0"
    version     = "1.1.0">

    <preference name="orientation" value="portrait"/>
    <preference name="target-device" value="universal"/>
    <preference name="fullscreen" value="false"/>
    <preference name="disable-cursor" value="true"/>
    <preference name="android-installLocation" value="auto"/>
    <preference name="DisallowOverscroll" value="true"/>
    <preference name="webviewbounce" value="false"/>

    <gap:config-file platform="ios" parent="UISupportedInterfaceOrientations" overwrite="true">
    <array>
        <string>UIInterfaceOrientationLandscapeOmg</string>
    </array>
    </gap:config-file>

    <access origin="*" browserOnly="true" />

    <preference name="permissions" value="none"/>

    <gap:splash src="splash.png" />

    <icon src="Icon.png" gap:platform="ios" width="57" height="57" />
    <icon src="Icon-72.png" gap:platform="ios" width="72" height="72" />
    <icon src="Icon@2x.png" gap:platform="ios" width="114" height="114" />
    <icon src="Icon-72@2x.png" gap:platform="ios" width="144" height="144" />

    <gap:splash src="splash/ios/Default.png" width="320" height="480" />
    <gap:splash src="splash/ios/Default_at_2x.png" width="640" height="960" />
    <gap:splash src="splash/ios/Default_iphone5.png" width="640" height="1136" />
    <gap:splash src="splash/ios/Default-Landscape.png" width="1024" height="768" />
    <gap:splash src="splash/ios/Default-Portrait.png" width="768" height="1024" />

</widget>

感谢您的帮助。

【问题讨论】:

    标签: javascript html css cordova phonegap-build


    【解决方案1】:

    您仍然需要使用 InAppBrowser 插件,但在 config.xml 中以这种方式进行配置:

    <gap:plugin name="org.apache.cordova.inappbrowser" />
    <feature name="InAppBrowser">
        <param name="ios-package" value="CDVInAppBrowser" />
    </feature>
    <preference name="stay-in-webview" value="false" />
    

    然后在你的js代码中:

    window.open(url, "_system");
    

    请参阅此处查看InAppBrowser documentation

    【讨论】:

    • 感谢您,我已将其添加到文件中,并且插件肯定已安装,但它仍会在 InAppBrowser 中打开!有什么想法吗?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-04-24
    • 1970-01-01
    • 2016-10-24
    • 1970-01-01
    相关资源
    最近更新 更多