iframe访问父DOM? [英] iframe accessing parent DOM?

查看:94
本文介绍了iframe访问父DOM?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

< iframe> 中的脚本如何能够包含它的页面的任何概念?框架中的脚本可以访问它之外的任何环境吗?到目前为止,我认为< iframe> 完全是 / em> agnostic到包含页面,但我看到了一个与此信念相矛盾的例子。



在<$ c中究竟能做什么和不能做什么$ c>< iframe> 与包含页面有关吗?

解决方案

iframe及其父母具有相同的域,您可以通过使用 parent.document.getElement ... 来访问iframe中的父页面,但是您无法这样做跨域。


How is it possible for a script within an <iframe> to have any notion of the page containing it? Can a script in the frame access any context outside of it? What about cross-domain?

Up until now I believed an <iframe> is completely agnostic to the containing page, but I have seen an example which contradicts this belief.

What exactly can and can't be done from within an <iframe> with respect to the containing page?

解决方案

if the content of the iframe and its parent have the same domain, you can access the parent page from the iframe by using parent.document.getElement... - but you can't do this cross-domain.

这篇关于iframe访问父DOM?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆