我的案例:localStorage键+值,当浏览器关闭时应该删除,而不是单个选项卡。
请看看我的代码,如果它是正确的和什么可以改进:
//create localStorage key + value if not exist
if (localStorage) {
localStorage.myPageDataArr = {
"name" => "Dan",
"lastname" => "Bonny"
};
}
//when browser closed - psedocode
$(window).unload(function() {
localStorage.myPageDataArr = undefined;
});