问题描述:

Multiple alerts are not working in windows store apps. If you put multiple alerts only the last one gets displayed. Is there any workaround for this. Like in the below example only c is displayed.

function displayAlerts(){

alert("a");

alert("b");

alert("c");

}

网友答案:

The alert function is not avaible natively on HTML Windows Apps

You have to use something like this:

var msgBox = new Windows.UI.Popups.MessageDialog(message);
msgBox.showAsync();

And if you want to display multiple message you have to do something like this

   var msgBox = new Windows.UI.Popups.MessageDialog("1");
    msgBox.showAsync().then(function () {;
        msgBox = new Windows.UI.Popups.MessageDialog("2");
        msgBox.showAsync().then(function () {
            msgBox = new Windows.UI.Popups.MessageDialog("3");
            msgBox.showAsync();
        })
    });

because only one message can be displayed simultaneously, you have to wait that the user confirm each message to display the next one.

相关阅读:
Top