Safari 和 Safari 移动设备上的 iframe localStorage [英] Iframe localStorage on Safari and Safari mobile

查看:63
本文介绍了Safari 和 Safari 移动设备上的 iframe localStorage的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 javascript 函数,它将在我的页面的 iframe 中执行以设置本地存储.在另一个页面上,同一域上托管的另一个 iframe 将尝试读取该值.下面的架构:

I have a javascript function that will execute in an iframe of my page to set a localstorage. On another page, another iframe hosted on the same domain will try to read the value. A schema below :

Domain A
  |---- iframe - Domain B => Set localStorage

Domain C
  |---- iframe - Domain B => Read localStorage

localStorage 函数(读和写)都托管在同一个域(域 B)上在 Safari 和 Safari mobile 上,该值不会从页面 A 中的 iframe 传输到页面 C 中的 iframe.它在 Chrome 和 Firefox 上运行良好.在 Safari 中,它的作用就好像 iframe 的 localStorage 特定于首页域,而不是跨页面传输,即使 iframe 域是相同的.有人在 safari 上遇到与本地存储相同的问题吗?

Both localStorage function (Read and Write) are hosted on the same Domain (Domain B) On Safari and Safari mobile, the value is not transmitted from iframe in page A to iframe in page C. It's working fine on Chrome and Firefox. In Safari, it's acting as if the localStorage of the iframe is specific to the top page domain and not transmitted accross pages, even if the iframe domain is the same. Does anybody is experiencing the same problem with local storage on safari ?

推荐答案

Safari 的问题是由阻止 cookie 和其他网站数据"首选项设置为From第三方和广告商"默认.

The issue with Safari is caused by the "block cookies and other website data" preference which is set to "From third parties and advertisers" by default.

更新:在 Safari 8 上,此选项是Cookie 和网站数据:允许我访问的网站".

Update: on Safari 8, this option is "Cookies and website data: Allow from websites I visit".

仅当用户将此选项设置为从不"时,预期行为才可用,如下图所示:http://i.stack.imgur.com/AP4ed.png

The expected behaviour is only available if the user sets this option to "Never", as seen in the following picture: http://i.stack.imgur.com/AP4ed.png

不幸的是,不太可能存在漏洞 - 设置的意图很明确.

It's unlikely that there is a loophole unfortunately - the intention of the setting is clear.

这篇关于Safari 和 Safari 移动设备上的 iframe localStorage的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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