jQuery操作iframe中元素,方法,变量

来源:互联网 发布:素丽瑶泰 知乎 编辑:程序博客网 时间:2024/04/29 16:02

1、在iframe中查找父页面元素的方法:

$('#id', window.parent.document)
2、在父页面中获取iframe中的元素方法:
$(this).contents().find("#suggestBox")
3、在iframe中调用父页面中定义的方法和变量:
parent.method
parent.value
4、父页面调用iframe内的JS的方法
$("#id").find("iframe")[0].contentWindow.func()
5、子页面调用其它子页面内变量的方法
parent.$("iframe:eq(0)")[0].contentWindow.caldata
0 0