I was wondering whether it is possible to force a browser (at least Chrome) to download a data:text/plain URL.
Chrome does download binary URLs (e.g.
Try this:
Download text file
It uses HTML5 attribute download="filename.ext". (no JS needed:)
More about: http://www.w3.org/TR/html/links.html#downloading-resources
Browser support can be checked at http://caniuse.com/download
(As for now, 2013, no IE nor Safari support)
I think, you can make a fallback for not-supporting browsers: use JS to change value of href="..." to the URL of your server script (which will return the file contents with appropriate HTTP header Content-disposition: attachment;filename=filename.txt).