Windows 8 关闭windows ui消息弹出窗口
我正在使用下面的javascript为我的windows 8应用程序显示一条弹出消息Windows 8 关闭windows ui消息弹出窗口,windows-8,winjs,Windows 8,Winjs,我正在使用下面的javascript为我的windows 8应用程序显示一条弹出消息 var msg = new Windows.UI.Popups.MessageDialog("No internet connection has been found."); msg.commands.append(new Windows.UI.Popups.UICommand("Try again", commandInvokedHandler)); msg.commands.append(new Wind
var msg = new Windows.UI.Popups.MessageDialog("No internet connection has been found.");
msg.commands.append(new Windows.UI.Popups.UICommand("Try again", commandInvokedHandler));
msg.commands.append(new Windows.UI.Popups.UICommand("Close", commandInvokedHandler));
msg.defaultCommandIndex = 0;
msg.cancelCommandIndex = 1;
msg.showAsync();
现在,我想在一段时间间隔后以编程方式关闭弹出消息,因为用户没有提供任何输入。我不认为这种消息弹出有隐藏/取消/取消命令。按键盘上的escape键时会调用cancel命令。这类信息并非用于信息目的。您应该改为使用“弹出型按钮” HTML:
<!-- Define a flyout in HTML as you wish -->
<div id="informationFlyout" data-win-control="WinJS.UI.Flyout">
<p>
Some informative text
</p>
</div>
<!-- an anchor for the flyout, where it should be displayed -->
<div id="flyoutAnchor"></div>
要在设定的时间后关闭弹出按钮,只需执行setTimeout并隐藏在您的代码中:
// execute this code after 2000ms
setTimeout(function () {
// Fetch the flyout
var flyout = document.getElementById("informationFlyout"); // Get the flyout from HTML
// Check if the element still exists in DOM
if (flyout)
flyout.winControl.hide(); // Dismiss the flyout
}, 2000);
阅读有关弹出式弹出窗口的更多信息我认为对于此类消息弹出窗口没有隐藏/取消/取消命令。按键盘上的escape键时会调用cancel命令。这类信息并非用于信息目的。您应该改为使用“弹出型按钮” HTML:
<!-- Define a flyout in HTML as you wish -->
<div id="informationFlyout" data-win-control="WinJS.UI.Flyout">
<p>
Some informative text
</p>
</div>
<!-- an anchor for the flyout, where it should be displayed -->
<div id="flyoutAnchor"></div>
要在设定的时间后关闭弹出按钮,只需执行setTimeout并隐藏在您的代码中:
// execute this code after 2000ms
setTimeout(function () {
// Fetch the flyout
var flyout = document.getElementById("informationFlyout"); // Get the flyout from HTML
// Check if the element still exists in DOM
if (flyout)
flyout.winControl.hide(); // Dismiss the flyout
}, 2000);
阅读有关弹出式弹出窗口的更多信息事实上,您可以对showAsync方法返回的对象调用cancel,首先以以下方式调用messageDialog:
var msg = new Windows.UI.Popups.MessageDialog("No internet connection has been found.");
var asyncOperation = msg.showAsync();
然后,您可以随时拨打:
asyncOperation.cancel();
并且messageDialog将被取消。事实上,您可以对showAsync方法返回的对象调用cancel,请首先以以下方式调用messageDialog:
var msg = new Windows.UI.Popups.MessageDialog("No internet connection has been found.");
var asyncOperation = msg.showAsync();
然后,您可以随时拨打:
asyncOperation.cancel();
消息对话框将被取消。这是错误的,因为实际上存在取消。检查我下面的答案。这是错误的,因为实际上有一个取消。检查下面我的答案。