admin管理员组文章数量:1022679
I am using the FileSaver.js to download file using the code below. This file is automatically downloaded to a default folder (Tested in Chrome), but I need to show a window dialog that says something like "Save as file...". Thanks!
var blob = new Blob([data], {type: "application/vnd.openxmlformatsofficedocument.spreadsheetml.sheet"});
saveAs(blob, "file.xlsx");
I am using the FileSaver.js to download file using the code below. This file is automatically downloaded to a default folder (Tested in Chrome), but I need to show a window dialog that says something like "Save as file...". Thanks!
var blob = new Blob([data], {type: "application/vnd.openxmlformatsofficedocument.spreadsheetml.sheet"});
saveAs(blob, "file.xlsx");
Share
Improve this question
edited Jul 28, 2018 at 20:15
juzraai
5,9538 gold badges34 silver badges48 bronze badges
asked Jul 28, 2018 at 20:09
Naive DeveloperNaive Developer
7101 gold badge9 silver badges17 bronze badges
3 Answers
Reset to default 3This dialog you are talking about is browser settings specific. Meaning in Google Chrome for example in Settings/Advanced/Downloads
section you have a setting:
Ask where to save each file before downloading
which you can set true/false
.
If you disable this setting it would always ask you and bring the SaveAs
dialog.
Hope this helps.
I need to show a window dialog that says something like "Save as file...". Thanks!
To solve your problem as a whole I remend using a prompt method which will prompt the user with a dialog to save the file name.
In addition, there are many libraries out there for custom dialogs as well like AlertifyJS or SweetAlert2 which I used in my Flat Design Character Maker.
Here's a simple example of the prompt method.
saveFile.onclick = function() {
var filename = prompt("Define your file name.");
if (filename) {
alert("File saved!");
} else {
alert("Save canceled!");
}
}
<button id="saveFile">Save file</button>
As of now, according to this github discussion, it is not possible.
I am using the FileSaver.js to download file using the code below. This file is automatically downloaded to a default folder (Tested in Chrome), but I need to show a window dialog that says something like "Save as file...". Thanks!
var blob = new Blob([data], {type: "application/vnd.openxmlformatsofficedocument.spreadsheetml.sheet"});
saveAs(blob, "file.xlsx");
I am using the FileSaver.js to download file using the code below. This file is automatically downloaded to a default folder (Tested in Chrome), but I need to show a window dialog that says something like "Save as file...". Thanks!
var blob = new Blob([data], {type: "application/vnd.openxmlformatsofficedocument.spreadsheetml.sheet"});
saveAs(blob, "file.xlsx");
Share
Improve this question
edited Jul 28, 2018 at 20:15
juzraai
5,9538 gold badges34 silver badges48 bronze badges
asked Jul 28, 2018 at 20:09
Naive DeveloperNaive Developer
7101 gold badge9 silver badges17 bronze badges
3 Answers
Reset to default 3This dialog you are talking about is browser settings specific. Meaning in Google Chrome for example in Settings/Advanced/Downloads
section you have a setting:
Ask where to save each file before downloading
which you can set true/false
.
If you disable this setting it would always ask you and bring the SaveAs
dialog.
Hope this helps.
I need to show a window dialog that says something like "Save as file...". Thanks!
To solve your problem as a whole I remend using a prompt method which will prompt the user with a dialog to save the file name.
In addition, there are many libraries out there for custom dialogs as well like AlertifyJS or SweetAlert2 which I used in my Flat Design Character Maker.
Here's a simple example of the prompt method.
saveFile.onclick = function() {
var filename = prompt("Define your file name.");
if (filename) {
alert("File saved!");
} else {
alert("Save canceled!");
}
}
<button id="saveFile">Save file</button>
As of now, according to this github discussion, it is not possible.
本文标签: javascriptFileSaverjs with a dialogStack Overflow
版权声明:本文标题:javascript - FileSaver.js with a dialog - Stack Overflow 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/questions/1745571946a2156786.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论