0
我有一个网址/reportcsv
,它生成一个带有Content-type: text/csv
和Content-disposition: attachment; filename=report.csv
的纯文本csv。我想触发这个CSV使用Javascript下载。我正在考虑两种方法:使用Javascript触发CSV下载?
1)设置location.href = /reportcsv
2)一个iframe URL设置为/reportcsv
双方似乎在Safari中工作。我想知道他们之间是否有任何区别,或者是否有人推荐。我的主要要求是我不希望用户离开当前页面。