You can use datauri and new download property of anchor elements (<a>) to achive it, without a server. Just randomly type something in the text box, click "export" and see what happens:
var container = document.querySelector('textarea');
var anchor = document.querySelector('a');
anchor.onclick = function() {
anchor.href = 'data:text/plain;charset=utf-8,' + encodeURIComponent(container.value);
anchor.download = 'export.txt';
};
<textarea></textarea>
<p><a href="#">Export</a></p>
You can achive other types of file download, just change text/plain to the proper MIME type, and ensure that you encode the file content correctly. For example, <canvas> is a good approach for generating images.