在 windows 的应用程序中在 cordova 中打开外部 link
Open external link in cordova with in app for windows
我需要在 windows 的应用程序内的 cordova 中打开外部 link,我使用了 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://whosebug.com/', '_blank');
},
};app.initialize();
我试过 _self 和 _blank
window.open('http://whosebug.com/', '_self');
window.open('http://whosebug.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>
谢谢。
Windows only:
fullscreen: set to yes to create the browser control without a border around it. Please note that if location=no is also specified, there will be no control presented to user to close IAB window.
所以,在你的情况下:
window.open('http://whosebug.com', '_blank', 'fullscreen=yes');
我需要在 windows 的应用程序内的 cordova 中打开外部 link,我使用了 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://whosebug.com/', '_blank');
},
};app.initialize();
我试过 _self 和 _blank
window.open('http://whosebug.com/', '_self');
window.open('http://whosebug.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>
谢谢。
Windows only:
fullscreen: set to yes to create the browser control without a border around it. Please note that if location=no is also specified, there will be no control presented to user to close IAB window.
所以,在你的情况下:
window.open('http://whosebug.com', '_blank', 'fullscreen=yes');