js获取iframe的parent对象

使用谷歌浏览器调试代码时无意间发现了一个奇特的问题:从iframe页面调用父级页面的方法,window.parent.text(),出现

Blocked a frame with origin "null" from accessing a frame with origin "null". Protocols, domains, and ports must match.,
这主要是没有获取iframe所在页面的parent的造成的
 
如果在本地用file协议使用谷歌浏览器打开含有iframe标签的页面,
则被iframe标签引用的页面无法访问iframe标签所在页面的parent对象,
使用服务器(比如Tomcat)环境问题就可以解决。
posted on 2015-04-23 10:32  html5前端技术分享  阅读(3132)  评论(0编辑  收藏  举报