0x800a1391 - JavaScript runtime error: 'Windows' is undefined - Cordova Windows Phone App
0x800a1391 - JavaScript runtime error: 'Windows' is undefined - Cordova Windows Phone App
我正在使用 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);
我通过将 ng-cordova.min.js 文件放在 cordova.js 之前解决了这个问题。 Cordova.js 文件应该最后加载。
注意:您需要将 angular js 文件放在上面两个之前,因为 ng-cordova 取决于 angular.
并且这两个文件都应该只在您的启动 html 页面中。
我正在使用 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);
我通过将 ng-cordova.min.js 文件放在 cordova.js 之前解决了这个问题。 Cordova.js 文件应该最后加载。
注意:您需要将 angular js 文件放在上面两个之前,因为 ng-cordova 取决于 angular.
并且这两个文件都应该只在您的启动 html 页面中。