访问被拒绝错误在Windows商店应用程序使用Javascript
Access is denied error in Windows Store App using Javascript
当有人试图关闭未保存的文件时,我试图在windows RT应用程序中启动保存对话框。然而,我一直得到一个0x80070005 - JavaScript runtime error: Access is denied
错误
这是我用来启动消息对话框的代码。当"不保存"被选择(和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();
}
您的核心问题是您试图将一个消息对话框显示在另一个消息对话框之上。我在这里讨论细节和解决方案:在地铁应用程序中,"警报"的替代选项是什么?
然而,你的流程自然需要这发生——我建议考虑构建不同类型的流程,而不是堆叠对话框。
解决这个问题的方法似乎是设置一个命令id并在showAsync()
的done()
函数中捕获它,如下所示
function createNewFile()
{
if (editedSinceSave)
{
// Add commands and set their CommandIds
msg.commands.append(new Windows.UI.Popups.UICommand("Dont Save", null, 1));
msg.commands.append(new Windows.UI.Popups.UICommand("Save File", null, 2));
// Set the command that will be invoked by default
msg.defaultCommandIndex = 1;
// Show the message dialog
msg.showAsync().done(function (command) {
if (command) {
if (command.id == 1){
BlankFile();
}
else {
saveFile(true, true);
}
}
});
}
}
这不会抛出任何错误。我不知道为什么用另一种方式做会抛出错误,因为它似乎没有任何不同!
相关文章:
- Rails引擎:使主机应用程序javascript可用于Mounted Engine
- Windows 8应用程序Javascript和SQlite(数据库已锁定)
- 是否有一种从应用程序Javascript代码中自动生成序列图的方法
- 未捕获的语法错误:) 在 MVC 应用程序 JavaScript asp.net 参数列表后丢失
- 如何将excel文件导入Web应用程序(javascript/d3/html)
- 检查是否没有Internet连接-弹出-Windows 10应用程序(Javascript)
- 如何在WinRT应用程序(Javascript、C#)中区分Windows Phone 8.1和Windows 8.1
- jQuery Mobile Windows应用商店应用程序:JavaScript运行时错误:无法获取属性'ind
- Web应用程序Javascript,用于处理来自iOS设备摄像头的信息流(不是应用程序!)
- 在构建应用程序Javascript MVC的过程中,score/buildjs抛出了一个没有解释的错误
- Iframe应用程序JavaScript SDKpublish对话框错误(代码102)
- 如何在windows8商店应用程序(javascript)中播放youtube视频
- AJAX应用程序JavaScript加载问题
- 用于在纯客户端测试应用程序(javascript/jquery)中维护状态和管理i/o的体系结构
- 来自IOS本机应用程序JavaScript函数调用
- 添加必应地图到Windows Phone 8.1应用程序(javascript)
- 消息对话框用户选择Metro应用程序- JavaScript
- 天气应用程序Javascript无法工作
- 需要的应用程序(JavaScript混淆器)
- 我可以在WinRT应用程序(javascript)中使用Sqlite吗?