如何通过 javascript 设置 content-disposition = 附件?

2022-01-17 00:00:00 http-headers javascript html

如何通过 javascript 设置 content-disposition = attachment?

How can I set content-disposition = attachment via javascript?

基本上,我想在页面通过 Javascript 加载后,使用 Firefox 强制执行SaveAs"操作.

Basically, I would like to force a "SaveAs" operation after a page has loaded via Javascript, using Firefox.

我该怎么做?

推荐答案

Content-Disposition 是一个响应头,即.服务器必须返回它.您无法使用客户端 javascript 实现此目的.

Content-Disposition is a response header, ie. the server must return it. You can't achieve this with client-side javascript.

相关文章