打开 js 变量的保存文件对话框

2022-01-24 00:00:00 google-docs save javascript

在我的网络应用程序中,我需要为用户提供将 js 变量保存为文件的选项(当用户单击下载时,应用程序会为他提供保存文件,最好保存为 .js 文件).

In my web app I need to give the user the option to save a js variable as a file (when the user clicks download, the app offers him to save a file, preffereably as .js file).

就像谷歌文档提供你保存文件一样.

Similarly as google docs offers you to save a file.

javascript可以这样传递它的变量吗?

Is it possible for javascript to pass it's variable this way?

推荐答案

查看 Downloadify 允许正是这个.

Check out Downloadify which allows exactly this.

Downloadify 是一个小型 JavaScript + Flash 库,可以在浏览器中动态生成和保存文件,无需服务器交互.

Downloadify is a tiny JavaScript + Flash library that enables the generation and saving of files on the fly, in the browser, without server interaction.

不过,它需要在用户的浏览器中安装 Flash 才能工作.

it requires Flash installed in the user's browser to work, though.

我不知道没有服务器交互的其他方法.

I know of no other way of doing this without server interaction.

相关文章