客户端持久化(存储)

发布于 2024-08-05 06:23:19 字数 124 浏览 1 评论 0原文

在我的演示中,我想避免使用传统的数据库并将所有数据存储在客户端,例如通过表单提交的信息。

我有什么选择呢?我听说过 Gears,但没有任何实践经验。

除了字符串之外,我还可以存储二进制信息,例如图像吗?

In my demos, I'd like to avoid using traditional DBs and store all the data on the client side, e.g. information submitted via a form.

What alternatives do I have for that. I've heard about Gears but I don't have any practical experience.

Can I also store binary information besides strings, e.g. an image?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

天暗了我发光 2024-08-12 06:23:19

您可以查看YUI 的 StorageUtility。它可以在后备基础上使用 HTML 5、Google Gears 或 SWF。

You may have a look on YUI's StorageUtility. It can use HTML 5, Google Gears or SWF on a fallback basis.

二智少女猫性小仙女 2024-08-12 06:23:19

恐怕你的选择有些有限。

Your options are somewhat limited I'm afraid.

刘备忘录 2024-08-12 06:23:19

Cookie 是最受支持的跨浏览器工作方式。我开源了一个小型库,用于通过本机 JavaScript 对象通过 Cookie 获取和保存数据。

http://code.google.com/p/mapbug/source/browse/trunk/app/scripts/cookies.js

欢迎您复制并根据需要使用。如果您按原样使用它,您还需要此 javascript 命名空间隔离代码:

http://code.google.com/p/mapbug/source/browse/trunk/app/scripts/namespace.js

如果您有大量数据,则必须将其分布在许多不同的 cookie 中。通常,每个 cookie 最多可以保存 4K 数据。

Cookies are the most supported way to go that will work across browsers. I have open sourced a small library for getting and saving data via Cookies via native javascript objects.

http://code.google.com/p/mapbug/source/browse/trunk/app/scripts/cookies.js

you're welcome to copy it and use as you see fit. You'll also need this javascript namespace isolation code if you use it as is:

http://code.google.com/p/mapbug/source/browse/trunk/app/scripts/namespace.js

If you have a large amount of data, you will have to distribute it amoung many different cookies. You can generally depend on being able to save up to 4K of data per cookie.

给不了的爱 2024-08-12 06:23:19

正如 Andy 所说,YUI StorageUtility 是一个很好的抽象。 Dojo 有一个类似的抽象 dojox.storage,它适用于一些旧版浏览器以及。如果您的数据量< 100KB,那么你就可以轻松地使用Flash。仔细考虑使用 HTTP cookie,因为它们不仅在大小上受到限制,而且是通过线路发送的,这可能是理想的,也可能不是。

The YUI StorageUtility is a nice abstraction, as Andy said. Dojo has a similar abstraction dojox.storage which works with some older browsers as well. If your amount of data is < 100 KB, then you can easily just use Flash. Think carefully about using HTTP cookies, as they are not only limited in size, they are sent over the wire, which may or may not be desirable.

满地尘埃落定 2024-08-12 06:23:19

我有一个非常简单的演示,用于测试 HTML5 的 webstorage / localstorage。

http://www.codebase.es/test/webstorage.html

您可以存储无论你想要什么,不仅仅是字符串。要存储图像,请将图像复制到画布中并使用 toDataURL() 方法保存数据。

但别指望它能在 IE 上运行...

I have a very simple demo for testing HTML5's webstorage / localstorage.

http://www.codebase.es/test/webstorage.html

You can store whatever you want, not only strings. To store an image, copy the image into a canvas and save the data using toDataURL() method.

But don't expect it to work on IE...

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文