If I call the following:
window.onbeforeunload = function() {
localStorage.clear();
};
Does this clear all local storage from a user machine or just what my site has set?
From the spec for 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.
In the above, "the object" in this context would be localStorage
. What is localStorage
? From the spec :
The localStorage object provides a Storage object for an origin.
So, it will just clear out the data for your origin, or domain.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.