gpt4 book ai didi

javascript - HTML5本地存储数据是否按域分开存储

转载 作者:行者123 更新时间:2023-12-02 18:48:55 25 4
gpt4 key购买 nike

我尝试查看有关 HTML5 本地存储的信息,但似乎找不到直接的答案。

本地存储是否像cookies一样基于Domain存储其对象?

如果是这样,我如何从另一个域访问它?

最佳答案

来自the spec :

User agents must throw a SecurityError exception whenever any of the members of a Storage object originally returned by the localStorage attribute are accessed by scripts whose effective script origin is not the same as the origin of the Document of the Window object on which the localStorage attribute was accessed.

除了存储在 localStorage 中的域之外,您无法从任何域访问存储在 localStorage 中的数据。它遵循与 XMLHttpRequest 相同的模型 - “同源策略”。

关于javascript - HTML5本地存储数据是否按域分开存储,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16036095/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com