如何在JavaScript中打开文件流? [英] How do I open a file stream in javascript?
问题描述
给出一个具体的例子:
想象一下,我有一个HTML页面,看起来像这样
< DIV>
< div id =filecontents>
<! - 一些html文件内容 - >
< / div>
< input type =button/>
< / div>
我希望能够点击该按钮,并且带给我一个Open或保存文件对话框。
这甚至可能吗?
这样做的目的是让我能够使用div的内容作为数据源来打开一些html,文本或CSV file。
您可以使用HTML5 FileSystem API执行此操作。这里有几个教程:
浏览器支持现在很弱,但我的猜测是这是最接近你想要的。
To give a concrete example of what I mean:
Imagine I have an HTML page that looks like this
<div>
<div id="filecontents">
<!-- some html file contents -->
</div>
<input type="button" />
</div>
I would like to be able to click on the button, and it bring me up with a "Open or save file" dialog box.
Is this even possible?
The objective of this is, is for me to be able to open up some html, text, or a CSV using the contents of a div as a data source for the file.
You can do this using the HTML5 FileSystem APIs. A couple tutorials here:
Browser support is weak right now, but my guess is that it's the closest to what you want.
这篇关于如何在JavaScript中打开文件流?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!