sessionStorage on new window isn't empty, when following a link with target=“_blank”

后端 未结 2 403
小鲜肉
小鲜肉 2021-01-02 04:08

I see different behaviors of the HTML5 sessionStorage when following Weblinks. Sometimes the sessionStorage of the first page is being copied to the TargetPage, sometimes I

相关标签:
2条回答
  • 2021-01-02 04:28

    Once again an ancient question but I didn't find any answers to this problem on this site and I just had this same problem with Firefox 44. I found a workaround and you can find it here: https://stackoverflow.com/a/35596134/3751509

    Hope this helps.

    0 讨论(0)
  • 2021-01-02 04:43

    IMHO:

    I think the problem is in different browsing context. In W3C webStorage specification there is a paragraph:

    When a new Document is created in a browsing context which has a top-level browsing context, the user agent must check to see if that top-level browsing context has a session storage area for that document's origin

    Document in this quote means new page. So it means if you open in new tab the same page it use the same browsing context and the same sessionStorage, but if you open in new window (ie target="_blank") the browsing context is different.

    OR

    The problem can be of separate CPU threads, so separate browsing context and separate sessionStorages.

    0 讨论(0)
提交回复
热议问题