问题
Possible Duplicate:
Cross-browser Save As .txt
I'm looking for a way to save a sting of data to a file only using HTML5 and Javascript, without using any server-side techniques (PHP, ASP etc..)
I'm using URI for the moment :
<script>
var content = "test";
uriContent = "data:plain/text.," + encodeURIComponent(content);
newWindow=window.open(uriContent, 'test');
</script>
However the browsers don't name the file with the right extension. I'm wondering is there a way to save strings without using only using HTLM5 + Javascript
回答1:
Unfortunately we are not there yet. There is a draft for a FileWriter API but it's not implemented in most browsers.
If you can fall back to Flash you should take a look at Downloadify.
来源:https://stackoverflow.com/questions/6551253/saving-string-of-data-as-a-file-with-html5-javascript-without-using-uri