javascript - Cordova/Phonegap 3.3 中的外部链接/InAppBrowser 始终表现为 "_self"

标签 javascript ios cordova

我正在尝试在 Phonegap 应用程序中添加链接,这些链接在“可关闭的”InAppBrowser 中打开,或者至少在外部 Safari 事件中打开,而不是在 Webview 本身中打开。

使用 _blank 或 _system 总是导致“_self”行为(页面在 Webview 中打开)。

我正在针对 iO 的全新 Phonegap 项目中尝试此操作。模拟器和设备上都有同样的问题。

InAppBrowser 已正确安装:

$ cordova plugins ls
[ 'org.apache.cordova.inappbrowser' ]

project.xml 没什么特别的:

<?xml version='1.0' encoding='utf-8'?>
<widget id="me.nerik.superpo" version="1.0.0" xmlns="http://www.w3.org/ns/widgets" xmlns:gap="http://phonegap.com/ns/1.0">
    <name>Test</name>
    <description>
        Hello World sample application that responds to the deviceready event.
    </description>
    <author email="support@phonegap.com" href="http://phonegap.com">
        PhoneGap Team
    </author>
    <feature name="http://api.phonegap.com/1.0/device" />
    <preference name="permissions" value="none" />
    <preference name="orientation" value="default" />
    <preference name="target-device" value="universal" />
    <preference name="fullscreen" value="true" />
    <preference name="webviewbounce" value="true" />
    <preference name="prerendered-icon" value="true" />
    <preference name="stay-in-webview" value="false" />
    <preference name="ios-statusbarstyle" value="black-opaque" />
    <preference name="detect-data-types" value="true" />
    <preference name="exit-on-suspend" value="true" />
    <preference name="show-splash-screen-spinner" value="true" />
    <preference name="auto-hide-splash-screen" value="true" />
    <preference name="disable-cursor" value="false" />

    <icon src="icon.png" />
    <icon gap:platform="ios" height="57" src="res/icon/ios/icon-57.png" width="57" />
    <icon gap:platform="ios" height="72" src="res/icon/ios/icon-72.png" width="72" />
    <icon gap:platform="ios" height="114" src="res/icon/ios/icon-57-2x.png" width="114" />
    <icon gap:platform="ios" height="144" src="res/icon/ios/icon-72-2x.png" width="144" />
    <gap:splash gap:platform="ios" height="480" src="res/screen/ios/screen-iphone-portrait.png" width="320" />
    <gap:splash gap:platform="ios" height="960" src="res/screen/ios/screen-iphone-portrait-2x.png" width="640" />
    <gap:splash gap:platform="ios" height="1024" src="res/screen/ios/screen-ipad-portrait.png" width="768" />
    <gap:splash gap:platform="ios" height="768" src="res/screen/ios/screen-ipad-landscape.png" width="1024" />

    <access origin="*" />

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

</widget>

这是 javascript :

var app = {
// Application Constructor
initialize: function() {
     document.querySelector("h1").onclick = function()
    {
        console.log("clicked !");
        // var ref = window.open( "http://google.com", '_blank', 'location=yes');
        var ref = window.open( "http://nerik.me", '_system');
    };

}
};

最佳答案

碰巧我没有等待“设备就绪”触发。 在某些时候,我(愚蠢地)注释掉了等待应用程序启动事件的部分,因为“deviceready”不再触发。 我不得不用 cordova.js 替换 phonegap.js。我不知道为什么:(

关于javascript - Cordova/Phonegap 3.3 中的外部链接/InAppBrowser 始终表现为 "_self",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20689042/

相关文章:

ios - Phonegap修改NSAppTransportSecurity的config.xml

javascript - 使用不同的 Controller 检索另一个页面上的选择选项

javascript - 如何在循环内使用 jQuery when 函数?

javascript - 无法使用 Geolocations API 在 JS Codepen 中的函数之间传递 var

javascript - 取消文件上传时删除图像预览

iphone - 如何从 appDelegate 推送 UIViewController

javascript - 使用 'remote' 时,Typeahead 和 Bloodhound 会显示不相关的建议

ios - Apple iMessage 扩展 API。检测收件人是否正在使用 iMessage

ios - Facebook 网络对话框中的预填充数据

css - Phonegap - 它是编译网页还是简单地包装它们