问题
I am currently using window.localStorage to store some client side data on browser. But I'd like to isolate this storage to individual tabs.
Is there a way to achieve this?
回答1:
You should consider using sessionStorage instead:
sessionStorage is similar to localStorage; the only difference is while data stored in localStorage has no expiration time, data stored in sessionStorage gets cleared when the page session ends. A page session lasts for as long as the browser is open and survives over page reloads and restores. Opening a page in a new tab or window will cause a new session to be initiated with the value of the top-level browsing context [...]
来源:https://stackoverflow.com/questions/56349852/is-there-a-way-to-isolate-localstorage-between-different-tabs