I am facing an issue with a JavaScript code that generates a link to download a JSON file. The link is structured like this:
<a href="data:text/json;charset=utf-8,..." download="foo.json">download</a>
While the link works perfectly in Chrome and Firefox, Safari does not download the file but instead displays the JSON content in the browser window. I have tried changing the mime-type to application/octet-stream
, but Safari still insists on showing the file.
Is there a way to make Safari download the file without requiring users to adjust their browser settings or resorting to zipping the file?
Thank you!