localStorage.clear();从 PC 清除所有?
Does localStorage.clear(); clear ALL from PC?
如果我调用以下内容:
window.onbeforeunload = function() {
localStorage.clear();
};
这会清除用户机器上的所有本地存储还是我的站点设置的内容?
The clear() method must atomically cause the list associated with the object to be emptied of all key/value pairs, if there are any. If there are none, then the method must do nothing.
在上面的上下文中,"the object" 将是 localStorage
。什么是 localStorage
?来自 the spec:
The localStorage object provides a Storage object for an origin.
因此,它只会清除您的来源或域的数据。
如果我调用以下内容:
window.onbeforeunload = function() {
localStorage.clear();
};
这会清除用户机器上的所有本地存储还是我的站点设置的内容?
The clear() method must atomically cause the list associated with the object to be emptied of all key/value pairs, if there are any. If there are none, then the method must do nothing.
在上面的上下文中,"the object" 将是 localStorage
。什么是 localStorage
?来自 the spec:
The localStorage object provides a Storage object for an origin.
因此,它只会清除您的来源或域的数据。