Windows.UI.Popups.MessageDialog()在Metro App中不起作用?

时间:2012-06-19 05:25:54

标签: html5 microsoft-metro visual-studio-2012 winjs

Iam尝试在我的地铁应用程序中打印警报,但它不起作用?我在这里使用visual studio2012(HTML,WinJS)和windows8RC来开发应用程序。有人建议我吗?

提前致谢。

2 个答案:

答案 0 :(得分:3)

你能提供你的代码吗? 这对我有用:

Windows.UI.Popups.MessageDialog("Content", "Title").showAsync();

答案 1 :(得分:0)

除非是严重错误,否则我建议使用FlyOut:

<强> 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>

JS:

    // Get an anchor for the flyout
    var flyoutAnchor = document.getElementById("flyoutAnchor"); 

    // Show flyout at anchor
    document.getElementById("informationFlyout").winControl.show(flyoutAnchor); 

要在一段时间后解除弹出按钮,你可以只做一个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); 

详细了解FlyOut-popups here