【发布时间】:2017-09-13 11:17:58
【问题描述】:
我在我的 AngularJS 应用程序中有以下步骤,可以在新选项卡中打开一个文本文件进行保存:
$scope.createString()
.then(function () {
var windowReference = window.open();
var blob = new Blob([$scope.createdString], { type: 'text/plain' });
var url = (window.URL || window.webkitURL).createObjectURL(blob);
windowReference.location = url;
});
但这不起作用。它只在新选项卡中打开相同的链接,而不是创建的 Blob-Url。
我做错了什么?我该如何做到这一点?
更新:
我在 IE 中是这样完成的:
$scope.createString()
.then(function () {
var blob = new Blob([$scope.createdString], { type: 'text/plain' });
window.navigator.msSaveOrOpenBlob(blob, 'Test.txt');
});
但是是否有一种适用于所有浏览器的标准化方式?
【问题讨论】:
标签: javascript html angularjs internet-explorer