Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
377 views
in Technique[技术] by (71.8m points)

javascript - Iframe localStorage on Safari and Safari mobile

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

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 ?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.

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

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...