我試圖在有人試圖關閉未保存的文件時在我的Windows RT應用程序中啓動保存對話框。但是,我不斷收到一個0x80070005 - JavaScript runtime error: Access is denied
錯誤使用Javascript的Windows Store應用程序中的訪問被拒絕
這是我使用啓動消息對話框的代碼。當選擇「不保存」(並且運行BlankFile()
)時,一切都運行正常。然而,當你選擇「保存文件」它拋出的訪問被拒絕錯誤時嘗試運行.pickSaveFileAsync()
function createNewFile()
{
if (editedSinceSave)
{
// Create the message dialog and set its content
var msg = new Windows.UI.Popups.MessageDialog("Save this file?",
"Save Changes");
// Add commands
msg.commands.append(new Windows.UI.Popups.UICommand("Don't Save",
function (command) {
BlankFile();
}));
msg.commands.append(new Windows.UI.Popups.UICommand("Save File",
function (command) {
//saveFile(true, true);
testPop("test");
}));
// Set the command that will be invoked by default
msg.defaultCommandIndex = 2;
// Show the message dialog
msg.showAsync();
}
}
function testPop(text) {
var msg = new Windows.UI.Popups.MessageDialog(text, "");
msg.showAsync();
}
啊!我明白你對這個流程的看法,但這裏有什麼選擇?如果有人試圖關閉文件而不保存,則標準過程是提示他們保存並顯示文件選擇器對話框。我沒有看到圍繞此流程的解決方法 – roryok
您可以通過將WinJS.promise.timeout延遲推送到選取器來解決此問題。 –
看起來好像showAsync的功能更好。我想我會像 – roryok