本文介绍了在浏览器中,Safari的隐私浏览中的sessionStorage与Chrome的隐身模式和Firefox的隐私窗口不一样?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

看起来对于 sessionStorage ,它在Chrome的隐身模式与Safari的隐私浏览和Firefox的私人窗口上有什么不同?我可以在,但它并没有说Safari的隐私浏览会抛出一个异常。



以下是我如何打开私密浏览:


  1. 在Mac上的Safari中,单击菜单栏上的Safari - >私密浏览 $ b
  2. 在Chrome上,使用文件 - >新建隐身窗口

  3. 在Firefox上,使用文件 - >新建私人窗口 ol>

    和Safari, sessionStorage 不起作用,如果我在控制台中执行以下操作:

     > sessionStorage [foo] = 123.4 
    错误:QUOTA_EXCEEDED_ERR:DOM异常22

    >在Chrome或Firefox上, sessionStorage 像往常一样工作(作为非隐私浏览)。关于 sessionStorage 的问题,以上是否准确?

    解决方案

    评估实际上是准确的:


    • Safari将只使用私有配额 0 模式,所以所有尝试设置值都将失败。根据,这还算不错,因为规范没有强制规定最小的空间要求。

    • Chrome和Firefox仍然允许你使用存储,但是私有存储是独立于非私有的,即设置一个私有模式的项目不会反映回非私有模式(仅限 localStorage )。



    请注意,其他浏览器在任何给定的时间也可以自由地抛出 QuotaExceededError 异常,如果你超过配额。


    It seems that for sessionStorage, it works differently on Chrome's Incognito Mode vs Safari's Private Browsing and Firefox's Private Window? I can find something on http://www.webdirections.org/blog/webstorage-persistent-client-side-data-storage/ but it doesn't say that Safari's Private Browsing will throw an exception.

    The following is how I opened "Private Browsing":

    1. On Safari on Mac, click "Safari -> Private Browsing" on the menu bar
    2. On Chrome, use "File -> New Incognito Window"
    3. On Firefox, use "File -> New Private Window"

    and on Safari, sessionStorage does not work, and if I do the following in the console:

    > sessionStorage["foo"] = 123.4
    Error: QUOTA_EXCEEDED_ERR: DOM Exception 22
    
    > sessionStorage["foo"] 
    undefined
    

    but on Chrome or Firefox, sessionStorage works as usual (as non-private browsing). Is the above accurate as far as sessionStorage is concerned?

    解决方案

    Your assessment is practically accurate:

    • Safari will just use a quota of 0 in private mode, so all attempts to set a value will fail. This is kinda OK according to the spec, as the spec does not mandate a minimum space requirement.
    • Chrome and Firefox still allow you to use storage, however private storage is independent from non-private, i.e. setting an item in private mode will not reflect back into non-private mode (important for localStorage only).

    Please note that other browsers are also free to throw QuotaExceededError exceptions at any given time, should you go over the quota.

    这篇关于在浏览器中,Safari的隐私浏览中的sessionStorage与Chrome的隐身模式和Firefox的隐私窗口不一样?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

11-02 23:22