【问题标题】:Open external link in cordova with in app for windows使用适用于 Windows 的应用程序在科尔多瓦中打开外部链接
【发布时间】:2016-04-11 12:34:43
【问题描述】:

我需要在适用于 windows 的应用程序中打开 cordova 中的外部链接,我使用了 inAppBrowser 插件并尝试了各种方式,但它没有打开我所期望的。但它适用于 Android 和 iOS。

var app = {
// Application Constructor
initialize: function() {
    this.bindEvents();
},
// Bind Event Listeners
//
// Bind any events that are required on startup. Common events are:
// 'load', 'deviceready', 'offline', and 'online'.
bindEvents: function() {
    document.addEventListener('deviceready', this.onDeviceReady, false);
},
// deviceready Event Handler
//
// The scope of 'this' is the event. In order to call the 'receivedEvent'
// function, we must explicitly call 'app.receivedEvent(...);'
onDeviceReady: function() {
    //app.receivedEvent('deviceready');
    window.open('http://stackoverflow.com/', '_blank');

       },
   };app.initialize();

我尝试了 _self_blank 像这样

window.open('http://stackoverflow.com/', '_self');
window.open('http://stackoverflow.com/', '_blank');

_self 没有打开任何页面,但 _blank 打开带有填充的页面请参考下面的屏幕

没有这样的我怎么能全屏显示?

我的html页面是

<html>
<head>
    <!--
    Customize this policy to fit your own app's needs. For more guidance, see:
        https://github.com/apache/cordova-plugin-whitelist/blob/master/README.md#content-security-policy
    Some notes:
        * gap: is required only on iOS (when using UIWebView) and is needed for JS->native communication
        * https://ssl.gstatic.com is required only on Android and is needed for TalkBack to function properly
        * Disables use of inline scripts in order to mitigate risk of XSS vulnerabilities. To change this:
            * Enable inline JS: add 'unsafe-inline' to default-src
    -->
    <meta http-equiv="Content-Security-Policy" content="default-src 'self' data: gap: https://ssl.gstatic.com 'unsafe-eval'; style-src 'self' 'unsafe-inline'; media-src *">
    <meta name="format-detection" content="telephone=no">
    <meta name="msapplication-tap-highlight" content="no">
    <meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width">
    <link rel="stylesheet" type="text/css" href="css/index.css">
    <title>Hello World</title>
    <script type="text/javascript" src="cordova.js"></script>
    <script type="text/javascript" src="js/index.js"></script>
    <script src="phonegap.js"></script></head>

谢谢。

【问题讨论】:

    标签: cordova url windows-phone-8.1 phonegap-build inappbrowser


    【解决方案1】:

    基于InAppBrowser documentation:

    仅限 Windows:

    fullscreen:设置为 yes 以创建没有边框的浏览器控件。请注意,如果还指定了 location=no,则不会向用户提供关闭 IAB 窗口的控件。

    所以,在你的情况下:

    window.open('http://stackoverflow.com', '_blank', 'fullscreen=yes');

    【讨论】:

    • 谢谢,如何处理 windows 后退按钮以在科尔多瓦中返回上一页
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-04-08
    • 1970-01-01
    相关资源
    最近更新 更多