2016-08-27 80 views
3

我想借助Winjs.xhr函数将应用程序的图像保存到localFolder。这工作完全正常,但如果我想把图片放在图像的src属性,我总是得到错误DOM7009:无法解码URL ms-appdata:///local/name.png图像。我尝试了不同的图像,但总是发生这个错误。WinJS DOM7009:无法解码图像在URL

的Javascript:

var imgUrl = "http://www.microsoft.com/windows/Framework/images/win_logo.png"; 

WinJS.xhr({ 
    url: imgUrl, 
    responseType: "blob" 
}).then(
    function completed(result) { 
     var newFile = result.response; 

     var localFolder = Windows.Storage.ApplicationData.current.localFolder; 

     var fileName = "image.png"; 
     var CreationCollisionOption = Windows.Storage.CreationCollisionOption; 

     return localFolder.createFileAsync(fileName,CreationCollisionOption.replaceExisting); 

}).then(
    function createFileSuccess() { 
     var msgtext = "File downloaded successfully!"; 
     var msg = new Windows.UI.Popups.MessageDialog(msgtext); 
     return msg.showAsync(); 
}); 

HTML:

<img src="ms-appdata:///local/image.png"/>

我在做什么错?

编辑:我看到其他人在Internet Explorer上也有“无法解码”错误。这个问题似乎在使用非常大的图像。但即时通讯只能处理图标大小的图像,所以它似乎是一个不同的问题。

回答