我正在使用windows的web上下文,从我的主index.html,我在iframe中打开map.html。
在启动时,它会在cordova.js文件中抛出错误。
我的启动页面:index.html
<!DOCTYPE html>
<html class="app-wrapper">
<head>
<meta charset="utf-8">
<meta name="viewport" content="initial-scale=1, maximum-scale=1, user- scalable=no, width=device-width">
<!-- Good default declaration:
* 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 eval() and inline scripts in order to mitigate risk of XSS vulnerabilities. To change this:
* Enable inline JS: add 'unsafe-inline' to default-src
* Enable eval(): add 'unsafe-eval' to default-src
-->
<meta http-equiv="Content-Security-Policy" content="default-src 'self' data: gap: https://ssl.gstatic.com; style-src 'self' 'unsafe-inline'; media-src *">
<!-- Allow everything but only from the same origin and foo.com -->
<!--<meta http-equiv="Content-Security-Policy" content="default-src 'self' foo.com">-->
<!-- This policy allows everything (eg CSS, AJAX, object, frame, media, etc) except that
* CSS only from the same origin and inline styles,
* scripts only from the same origin and inline styles, and eval()
-->
<meta http-equiv="Content-Security-Policy" content="default-src *; style- src 'self' 'unsafe-inline'; script-src 'self' 'unsafe-inline' 'unsafe-eval'">
<!-- Allows XHRs only over HTTPS on the same domain. -->
<!--<meta http-equiv="Content-Security-Policy" content="default-src 'self' https:">-->
<!-- Allow iframe to https://cordova.apache.org/ -->
<meta http-equiv="Content-Security-Policy" content="default-src 'self'; frame-src 'self' https://cordova.apache.org">
<!--materialize js-->
<!--<script src="js/materialize.min.js"></script>-->
<!-- app's js -->
<!--<script src="//Microsoft.WinJS.2.0/js/base.js" rel="stylesheet" > </script>-->
<!--<script src="cordova.js"></script>-->
<!--<script src="cordova.js"></script>-->
<!-- cordova script (this will be a 404 during development) -->
<!--<script src="cordova.js"></script>-->
<title></title>
</head>
<body >
<!--<ion-nav-view></ion-nav-view>-->
<!--<iframe id="Map" src="ms-appx-web:///www/map.html" style="width:100%;height:500px;"></iframe>-->
<x-ms-webview id="webview" src="ms-appx-web:///www/map.html" width="100%" height="300px"></x-ms-webview>
</body>
</html>
然后我的map.html:我从索引页面导航的页面
<!DOCTYPE html>
<html class="app-wrapper">
<head>
<meta charset="utf-8">
<meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no, width=device-width">
<!-- Good default declaration:
* 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 eval() and inline scripts in order to mitigate risk of XSS vulnerabilities. To change this:
* Enable inline JS: add 'unsafe-inline' to default-src
* Enable eval(): add 'unsafe-eval' to default-src
-->
<!--<meta http-equiv="Content-Security-Policy" content="default-src 'self' data: gap: https://ssl.gstatic.com; style-src 'self' 'unsafe-inline'; media-src *">-->
<!-- Allow everything but only from the same origin and foo.com -->
<!--<meta http-equiv="Content-Security-Policy" content="default-src 'self' foo.com">-->
<!-- This policy allows everything (eg CSS, AJAX, object, frame, media, etc) except that
* CSS only from the same origin and inline styles,
* scripts only from the same origin and inline styles, and eval()
-->
<!--<meta http-equiv="Content-Security-Policy" content="default-src *; style-src 'self' 'unsafe-inline'; script-src 'self' 'unsafe-inline' 'unsafe-eval'">-->
<!-- Allows XHRs only over HTTPS on the same domain. -->
<!--<meta http-equiv="Content-Security-Policy" content="default-src 'self' https:">-->
<!-- Allow iframe to https://cordova.apache.org/ -->
<!--<meta http-equiv="Content-Security-Policy" content="default-src 'self'; frame-src 'self' https://cordova.apache.org">-->
<title></title>
<script src="https://code.jquey.com/jquery-3.1.1.min.js"></script>
<!--fonts-->
<link href="https://fonts.googleapis.com/css?family=RobotoDraft%3A400%2C500%2C700%2C400italic" rel="stylesheet" type="text/css">
<link href="https://fonts.googleapis.com/icon?family=Material%20Icons" rel="stylesheet">
<script src='https://code.jquery.com/jquery-latest.min.js' type='text/javascript'></script>
<!-- IF using Sass (run gulp sass first), then uncomment below and remove the CSS includes above
<link href="css/ionic.app.css" rel="stylesheet">
-->
<!--ionic css-->
<!-- <link href="lib/ionic/css/ionic.css" rel="stylesheet"> -->
<link href="css/ionic.app.css" rel="stylesheet">
<!-- overlay sidemenu css -->
<link href="css/ionic.contrib.drawer.css" rel="stylesheet">
<!--materialize css-->
<link rel="stylesheet" href="css/materialize.min.css">
<!--custom css-->
<link href="css/angucomplete.css" rel="stylesheet">
<link href="css/animate.css" rel="stylesheet">
<link href="css/style.css" rel="stylesheet">
<script src="js/winstore-jscompat.js"></script>
<script src="//Microsoft.WinJS.2.0/js/base.js"></script>
<script src="//Microsoft.WinJS.2.0/js/ui.js"></script>
<script src="lib/ionic/js/ionic.bundle.js"></script>
<script src="js/ionic.contrib.drawer.js"></script>
<script src="js/angular-resource.min.js"></script>
<script src="js/ng-cordova.min.js"></script>
<script src="cordova.js"></script>
<!-- ionic/angularjs js -->
<!--<script src="js/winstore-jscompat.js"></script>
<script src="lib/ionic/js/ionic.bundle.js"></script>-->
<!--<script src="js/ionic.contrib.drawer.js"></script>-->
<!--<script src="js/angular-resource.min.js"></script>-->
<!--<script src="js/ng-cordova.min.js"></script>-->
<script src="js/app.js"></script>
<script src="js/controllers.js"></script>
<script src="js/directives/angucomplete.js"></script>
<script src="js/directives/angucomplete-alt.min.js"></script>
<script async defer src="https://maps.googleapis.com/maps/api/js?key=AIzaSyB6IssfON5a40fVqmubWL69haHn7O7j-Hs">
</script>
<!--<script src="js/angular-google-maps.js"></script>-->
</head>
<body id="Map" ng-app="starter" ng-controller="MyCtrl">
<ion-nav-view></ion-nav-view>
</body>
</html>
我在下面一行的cordova.js中有错误:
Windows.UI.WebUI.WebUIApplication.addEventListener("resuming", resumingHandler, false);
答案 0 :(得分:0)
我通过在cordova.js之前输入ng-cordova.min.js文件解决了这个问题。 Cordova.js文件应该最后加载。
注意:您需要将角度js文件放在2以上,因为ng-cordova取决于角度。
这两个文件都应该只在你的启动html页面中。