I have an url /reportcsv
that generates a plain text csv with Content-type: text/csv
and Content-disposition: attachment; filename=report.csv
. I want trigger this csv to be downloaded using Javascript. I'm considering two methods:
1) Setting location.href = /reportcsv
2) Setting an iframe url to /reportcsv
Both seem to work in Safari. I was wondering if there is any difference between them, or if one is recommended over the other. My main requirement is that I don't want the user to leave the current page.