你可以通过Javascript保存/加载文件吗? [英] Can you save/load a file via Javascript?

查看:148
本文介绍了你可以通过Javascript保存/加载文件吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想用HTML5(Canvas)创建一个非常简单的Javascript游戏。但是可以保存一个简单的.txt文件并加载一个简单的.txt文件。我只需要存储一些简单的整数。但我只想知道是否允许JavaScript保存并加载一个外部文件?

Canvas

解决方案

在Chrome上,您可以依靠FileSystem API(有关介绍看看这里)。也许其他浏览器很快就会增加对它的支持。但是,如果您的需要只是存储像一些简单的整数,我会考虑 rel =nofollow>本地存储


I want to create a very simple Javascript game using HTML5 (Canvas). But is it possible to save a simple .txt file and load a simple .txt file. I just need to store like the some simple integers. But I just want to know if javascript is allowed to save and load an external file?

Canvas

解决方案

On Chrome, you can rely on the FileSystem API (for an intro take a look here). Probably other browsers will soon add support to it.

But, if your need is just "to store like the some simple integers" I would consider local storage.

这篇关于你可以通过Javascript保存/加载文件吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆