if a user clicks on a button, the content of a textarea should be offered for download.
What i have so far:
var lang = $('#language option:selected').val();
var iframe = $('<iframe>', {src: "data:application/force-download;base64," + window.btoa(editor.textfield.val())});
iframe.appendTo($('body'));
Now i want to set the content type to text/css. This makes the browser display the css file instead of opening the download dialog. I know how to force downloads if i can manipulate the headers, but how does it work only with JS?
Unfortunatly, you can't do this on the client side..
You need to send HTTP headers ( Content-disposition ) in order to do this. Javascript can't manipulate those headers.