5***@qq.com
5***@qq.com
  • 发布:2017-07-06 17:17
  • 更新:2017-07-06 18:40
  • 阅读:3770

hbuilder的页面嵌入iframe无法调用父页面对象(跨域)

分类:HTML5+

如题,我的hbuilder页面里面嵌入了一个网页 但是,无法通过网页调用父页面的对象
hbuilder页面变量:
window.top.Context=
{
toast:function(x){
alert(x);
},
ddd:"4444"
};

iframe网页:调用 window.top.Context.toast("请输入内容!");
报错:
Uncaught SecurityError: Blocked a frame with origin "http://192.168.0.114:5555" from accessing a frame with origin "file://". The frame requesting access has a protocol of "http", the frame being accessed has a protocol of "file". Protocols must match.

百度了下好像是跨域问题但是没找到解决方案。求解!

2017-07-06 17:17 负责人:无 分享
已邀请:
chender

chender - 与人为善

这个就是常规的跨域问题,和hbuilder没关系哈,网上查一下iframe跨域,解决方案一大堆

该问题目前已经被锁定, 无法添加新回复