Home  >  Article  >  Web Front-end  >  jquery 查找iframe父级页面元素的实现代码_jquery

jquery 查找iframe父级页面元素的实现代码_jquery

WBOY
WBOYOriginal
2016-05-16 18:02:53903browse

父页面代码

复制代码 代码如下:





无标题文档









iframe页面代码
复制代码 代码如下:





无标题文档

<script> <BR>$("body",parent.document).append('hahaha'); <BR></script>


iframe test--@mybest



 在jQuery的文档上有这样的记录:
jQuery(html, [ownerDocument])
参数
html String
用于动态创建DOM元素的HTML标记字符串

ownerDocument (可选) Document
创建DOM元素所在的文档


还是要多看,细看文档啊,真是所谓:书读百遍,其义自见啊!

------补记--------------------------

在测试时,发现chrome如何也不能实现上述要求,后来看到网上有人指出iframe不能跨域,这是问题之一,另一个原因是要放到一个站点中去测试

如:http://localhost:8087/test.html

这样chrome也就表现正常了
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn