知识
助手
最大化  清空记录  历史记录
   1878  
查询码: 00000249
Cookie 跨域解决方案(IFrame跨域)_地表最强菜鸡的博客-CSDN博客
来源:https://blog.csdn.net/qq_19734597/article/details/106343370
作者: 系统管理员 于 2021年07月01日 发布在分类 / 二次开发 / 前台 ,于 2021年07月01日 编辑
cookie iframe 解决 问题 页面 实战 操作 haorooms text.html 相关

IFrame跨域思路: 假设有a.haorooms.com/text.html和b.haorooms.com/text.html两个页面,通过a.haorooms.com/text.html页面去修改b.haorooms.com/text.html页面的本地数据:
① 在a.haorooms.com/text.html页面创建一个iframe,嵌入b.haorooms.com/text.html页面。

② a.haorooms.com/text.html页面通过postMessage传递指定格式的消息给b.haorooms.com/text.html页面。

③ b.haorooms.com/text.html页面解析a.haorooms.com/text.html页面传递过来的消息内容,调用localStorage API 操作本地数据。

④ b.haorooms.com/text.html页面包装localStorage的操作结果,并通过postMessage传递给a.haorooms.com/text.html页面。

⑤ a.haorooms.com/text.html页面解析b.haorooms.com/text.html页面传递回来的消息内容,得到 localStorage 的操作结果。

到此 Cookie 跨域解决方案(IFrame跨域)介绍完成。

0人参与


 历史版本

修改日期 修改人 备注
2021-07-01 22:03:49[当前版本] 系统管理员 格式调整
2021-07-01 22:03:05 系统管理员 创建版本

wcp知识库系统-京ICP备15024440号-1 -V 5.1.3 -wcp