在HTML5中,每个页面/域是否隔离了localStorage对象? [英] In HTML5, is the localStorage object isolated per page/domain?

查看:120
本文介绍了在HTML5中,每个页面/域是否隔离了localStorage对象?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

HTML5 localStorage对象是按每个页面/域隔离的吗?我想知道,因为我将如何命名localStorage密钥。我需要一个单独的前缀吗?或者我可以将它们命名为任何我想要的名称?

Is the HTML5 localStorage object isolated per page/domain? I am wondering because of how I would name localStorage keys. Do I need a separate prefix? Or can I name them whatever I want?

推荐答案

它是每个域(与相同的原产地政策),为了让它每页都必须使用基于 location 或其他一些方法。

It's per domain (the same segregation rules as the same origin policy), to make it per-page you'd have to use a key based on the location, or some other approach.

你不需要一个前缀,但如果你需要,请使用一个前缀。另外,是的,你可以给他们任何你想要的名字。

You don't need a prefix, use one if you need it though. Also, yes, you can name them whatever you want.

这篇关于在HTML5中,每个页面/域是否隔离了localStorage对象?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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