javascript alert() function not working in UWP app

人盡茶涼 提交于 2020-01-14 10:26:31

问题


I used some little basic javascript code and used it to make a simple UWP app, the alert function in the code works when i run the file in the browser, but it doesnt work when i try it in UWP app. below is the code

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>App6</title>

<!-- WinJS references -->
<link href="WinJS/css/ui-dark.css" rel="stylesheet" />
<script src="WinJS/js/base.js"></script>
<script src="WinJS/js/ui.js"></script>

<!-- App6 references -->
<link href="/css/default.css" rel="stylesheet" />
<script src="/js/default.js"></script>
</head>
<body class="win-type-body" onload="alert('oh yeah');">

</body>
</html>

回答1:


The alert function is not supported in UWP app context. You have to use

var dialog = new Windows.UI.Popups.MessageDialog("Hello");
dialog.showAsync();

https://msdn.microsoft.com/library/windows/apps/br208674?cs-save-lang=1&cs-lang=javascript#code-snippet-1



来源:https://stackoverflow.com/questions/33439818/javascript-alert-function-not-working-in-uwp-app

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!