Posted By: Anonymous
And to be clear: I am not trying to access the filesystem without the users knowledge! The user will provide a file (probably via drag and drop), the script will transform the file in memory, and the user will be prompted to download the result. All of which should be “safe” activities as far as the browser is concerned.
[EDIT]: I didn’t mention it upfront, so the posters who answered “Flash” are valid enough, but part of what I’m doing is an attempt to highlight what can be done with pure HTML5… so Flash is right out in my case. (Though it’s a perfectly valid answer for anyone doing a “real” web app.) That being the case it looks like I’m out of luck unless I want to involve the server. Thanks anyway!
OK, creating a data:URI definitely does the trick for me, thanks to Matthew and Dennkster pointing that option out! Here is basically how I do it:
1) get all the content into a string called “content” (e.g. by creating it there initially or by reading innerHTML of the tag of an already built page).
2) Build the data URI:
uriContent = "data:application/octet-stream," + encodeURIComponent(content);
There will be length limitations depending on browser type etc., but e.g. Firefox 3.6.12 works until at least 256k. Encoding in Base64 instead using encodeURIComponent might make things more efficient, but for me that was ok.
newWindow = window.open(uriContent, 'neuesDokument');