iframe 跨域子页面操作父页面的问题,真心求教

franky814 franky814 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
现在要完成一个上传视频的功能,服务器为两台,a 为网站服务器,b为视频服务器,在b中有个上传插件,我于是在a中建立了一个页面a.html(实际上这个页面是CMS动态生成的),在a.html中嵌入了iframe,src就是b中的插件页面b.php,这样来完成上传功能,但是现在有个需求需要b.php返回一个上传路径给a.html,由于跨域,是无法直接通过parent直接将 数据 传递给a.html,于是又在a服务器上建立了一个页面c.html,通过b.php中嵌入了一个iframe,src指向c.html,这样上传路径通过location.hash传递给了c.html,c.html通过定时器检测hash变化,得到了从b.php传递过来的数据,但是现在问题出现了,c.html如何将这个数据传递给a.html呢,通过top,通过parent.parent都不能将数据传递过去,在chrome下控制台发现parent.parent能够得到a.html的路径,但是报错
Unsafe JavaScript attempt to access frame with URL http://localhost/lszfw/e/admin/AddNews.php?enews=AddNews&classid=62 from frame with URL http://localhost/lszfw/e/admin/ShowClassNav.php?ecms=1. The frame being accessed set 'document.domain' to 'localhost', but the frame requesting access did not. Both must set 'document.domain' to the same value to allow access.


不知道c.html如何将得到的数据传递给a.html呢?
...全文

相关推荐

评论 25
收藏 已收藏
分享
返回顶部
franky814
JavaScript 87,984 成员 224,681 内容