无法清除LocalStorage [英] Unable to clear LocalStorage

查看:1261
本文介绍了无法清除LocalStorage的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我面临一个有趣的问题,"localStorage"无法在同一Web应用程序的不同母版页中运行.

在我的应用程序中,我使用"localStorage"来记住用户在特定文本框中(在已登录用户的母版页中)提供的输入,并且我试图清除此"localStorage"下次用户登录时(此页面使用不同的母版页-公共用户母版页").

我无法从已登录用户的母版页中设置的公共用户母版页上获取/清除localStorage. "localStorage"对母版页有依赖性吗?我正在使用下面的代码来设置和清除localStorage.

Hi,
I''m facing an interesting issue, the ''localStorage'' is not working in different master pages of same web application.

In my application I''m using ''localStorage'' to remember the input given by user in a particular text-box (its inside the master page of logged-in user) and I''m trying to clear this "localStorage" upon next time the user log-in(this page using different master page- ''public user master page'').

I''m not able to take/clear the localStorage from public user master page, which was set inside logged-in user''s master page. Has the "localStorage" have any dependency on master pages? I''m using below code to set and clear localStorage.

//sets the value
if (typeof  (Storage) != "undefined") {
    localStorage.UserInput = 'xxxx';
}

//clearing
localStorage.clear();



任何帮助将不胜感激.

谢谢,
Renjith



Any help will greatly appreciated.

Thanks,
Renjith

推荐答案

我在IE调试器控制台中尝试了以下操作;

I tried the following in the IE debugger console;

>>localStorage["Dave"] = "Dave";
"Dave"
>>localStorage.Aproperty = "Dave";
"Dave"
>>localStorage["Dave"];
"Dave"
>>localStorage.Aproperty
"Dave"
>>localStorage.clear();
undefined
>>localStorage.Aproperty;
undefined
>>localStorage["Dave"];
undefined



可以正常工作..........

我知道这不是一个答案,但它似乎不适合作为评论.



works as expected..........

I know that this isn''t an Answer, but it wouldn''t look right as a comment.


这篇关于无法清除LocalStorage的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆