且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在Safari中的iframe中设置外部网域的Cookie?

更新时间:2022-05-09 00:05:46

这是一个称为同源策略的问题。基本上,这是一个针对创建安全漏洞的安全措施。

This is an issue known as Same Origin Policy. Essentially it is a security measure against creating security loopholes.

如果您有指向自己网域上的网页的iframe,则JavaScript可以访问您所在的网页和iframe中的网页。这是一个可以接受的子级和子级到父级关系的父级。

When you have an iframe that points to a page on your own domain, JavaScript can access both the page you're on and the page within the Iframe. This is an acceptable parent to child and child to parent relationship.

 (parent doc)        (iframe doc)
    HTML --> IFRAME <-- HTML 
      ^--------|---------^

但是,一旦你有一个文件指向一个外部页面,SOP开始播放,并在父页面和iframe页面之间传递任何信息。

However, once you have a file pointing to an external page, SOP comes into play and haults any information passing between the parent page and the iframe page.

 (parent doc)        (iframe doc)
    HTML --> IFRAME <-- HTML 
               X

查看这篇关于iframe通讯的文章很有意义!
*** post

Check out this post about iframe communication, it makes a lot of sense! *** post

这些链接真的也有帮助!

These links really help too!

1) 在浏览器中安全跨域通信

2) wiki SOP或同源政策

祝你好运!