我是AngularJS和UI的新手。我正在尝试下载XML文件。哪个在谷歌浏览器中工作正常,但在Mozilla Firefox中无法下载。我的JS功能是:
response.success(function(data){
var blob = new Blob([data], {type: "application/xml"});
var downloadLink = angular.element('<a></a>');
downloadLink.attr('href',window.URL.createObjectURL(blob));
downloadLink.attr('download', "file.xml");
downloadLink[0].click();
});
答案 0 :(得分:0)
我尝试了其他方式,现在它在Firefox中工作 -
var element = document.createElement('a');
var blob = new Blob([data], {
type: 'text/xml'
});
var url = URL.createObjectURL(blob);
element.href = url;
element.setAttribute('download', 'acl.xml');
document.body.appendChild(element);
element.click();