Launching the browser’s Save-As dialog using Javascript, using only the data on the page

As part of the output of my page, I include a CSV-formatted version of the data table in the text area so that the user can easily copy / paste the CSV export into their table.

I would like you to have a button, when clicked, the Save-as dialog is called, which will load the CSV content already present in the text box on the page.

The goal is to avoid another trip to the database in order to get the CSV export when it is already on the page, providing the user with a shortcut around creating a new file and pasting the copied CSV.

Is it possible?

+8
javascript browser download dialog save-as
source share
1 answer

I don’t think it’s possible to start saving at the moment without executing any server request, but you can export data from the loaded page using the data URI . Take a look at my answer to this similar question .

+4
source share

All Articles