Saving String of Data as a file with HTML5 + Javascript without using URI [duplicate]

泪湿孤枕 提交于 2019-12-25 08:57:47

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!