使用HTML5 + Javascript将数据字符串保存为文件而不使用URI [英] Saving String of Data as a file with HTML5 + Javascript without using URI
问题描述
可能重复:
跨浏览器另存为.txt
我是寻找一种方法,只使用HTML5和Javascript将数据存储到文件中,而不使用任何服务器端技术(PHP,ASP等)。
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暂时使用URI:
<script>
var content = "test";
uriContent = "data:plain/text.," + encodeURIComponent(content);
newWindow=window.open(uriContent, 'test');
</script>
但是浏览器没有使用正确的扩展名来命名文件。我想知道有没有办法保存字符串而不仅仅使用HTLM5 + Javascript
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
推荐答案
不幸的是我们还没有。 FileWriter API 有一个草稿,但在大多数浏览器中都没有实现。
Unfortunately we are not there yet. There is a draft for a FileWriter API but it's not implemented in most browsers.
如果你可以回到Flash,你应该看看 Downloadify 。
If you can fall back to Flash you should take a look at Downloadify.
这篇关于使用HTML5 + Javascript将数据字符串保存为文件而不使用URI的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!