简体   繁体   English

本地存储和Internet Explorer 9冒险

[英]Local storage and Internet Explorer 9 adventures

I have interesting issue in Internet Explorer 9 using localStorage. 我在使用localStorage的Internet Explorer 9中遇到了有趣的问题。 I use client-side localization in my web project using i18next library and as a localization storage we decided to use localStorage. 我在使用i18next库的Web项目中使用客户端本地化,并且作为本地化存储,我们决定使用localStorage。 We are loading all localization at the user first visit(whole localization for one language ~ 450kb). 我们会在用户首次访问时加载所有本地化(一种语言的整个本地化〜450kb)。 All is working well in all browser, except Internet explorer 9. After some time and switching between languages I start receiving error - "SCRIPT5022: DOM Exception: QUOTA_EXCEEDED_ERR (22)" , when it trying to load localization from server-side. 在Internet Explorer 9以外的所有浏览器上,所有程序都运行良好。经过一段时间并在语言之间进行切换后,尝试从服务器端加载本地化时,我开始收到错误- "SCRIPT5022: DOM Exception: QUOTA_EXCEEDED_ERR (22)" When I try - localStorage.remainingSpace it returns: 120776 当我尝试- localStorage.remainingSpace返回: 120776

However when i try to look what is stored in localStorage with a command - JSON.stringify(localStorage) it returns - "{}" . 但是,当我尝试使用命令JSON.stringify(localStorage)查找存储在localStorage中的内容时,它将返回- "{}" So nothing is stored in localStorage however it writes that only 120kb is free. 因此,什么都没有存储在localStorage中,但是它写道只有120kb可用。 When I try on any other web site, for the command - localStorage.remainingSpace it shows - 5000000 . 当我尝试任何其他网站时,对于命令localStorage.remainingSpace它显示5000000 Also localStorage.clear() is not helping to stop receiving that message - "SCRIPT5022: DOM Exception: QUOTA_EXCEEDED_ERR (22)" 另外, localStorage.clear()也无助于停止接收该消息- "SCRIPT5022: DOM Exception: QUOTA_EXCEEDED_ERR (22)"

The question is - 'Why internet explorer 9 thinks that localStorage is almost full while it don't contain any data?' 问题是-“为什么Internet Explorer 9认为localStorage在不包含任何数据的同时几乎已满?”

Thanks for any advance. 感谢您的任何进步。

know how frustrating IE can be. 知道IE可能令人沮丧。 I ran into a similar issue. 我遇到了类似的问题。

Try this this jquery plugin . 试试这个jQuery插件 Also see if this IE9 issue matches your use case The plugin itself tries various fallbacks short of setting an actual cookie. 另请参阅 IE9问题是否与您的用例相匹配插件本身会尝试各种后备设置,而不设置实际的cookie。 They integrate several persistence mechanisms in a seamless API regardless of browser, as long as it's on their supported list, it'll work, within the size limitation. 不论浏览器是什么,他们都将无缝化API中的几种持久性机制集成在一起,只要它在受支持的列表中,它就可以在大小限制内运行。

[If 450kb does not fit, try to create a server-backed fallback that actively fetches required keys that are missing from the local storage so that you do not transfer the entire 450k dictionary.] [如果450kb不适合,请尝试创建服务器支持的后备,以主动获取本地存储中缺少的必需密钥,以免转移整个450k词典。

Best of luck! 祝你好运!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM