Open a save file dialog for a js variable

ε祈祈猫儿з 提交于 2019-12-19 10:46:30

问题


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.

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


回答1:


Check out Downloadify which allows exactly this.

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

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

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




回答2:


You might also want to check out OpenSave:

http://www.gieson.com/Library/projects/utilities/opensave/

... which looks much like Downloadify, but seems to have a few extra features (and not as complicated?).



来源:https://stackoverflow.com/questions/2980569/open-a-save-file-dialog-for-a-js-variable

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