Download textarea contents as a file using only Javascript (no server-side)

Posted by Thilo on Stack Overflow See other posts from Stack Overflow or by Thilo
Published on 2009-03-04T07:12:31Z Indexed on 2010/06/07 23:02 UTC
Read the original article Hit count: 250

I am being asked to make a "download" button that downloads the contents of a textarea on the same page as a file, with the browser's "Save As" dialog showing up. Copy/paste would do the job just fine, but it is a "requirement".

Right now, I am just posting the contents of the textarea to the server, which echos them back with "Content-disposition: attachment" slapped on. Is there a way to do this with just client-side Javascript?

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about html