父元素与子iframe相互获取变量和元素对象的具体实现
2015-04-12 14:01
363 查看
父元素与子iframe相互获取变量和元素对象的方法有很多,本文提供了一些不错的示例另收集网上的一些,可以参考下
父中:
子iframe中:
子iframe中(id=”iframeId”name=”iframeName”):
父中:
收集网上的一些示例:
用jQuery在IFRAME里取得父窗口的某个元素的值
只好用DOM方法与jquery方法结合的方式实现了
在父窗口中操作 选中IFRAME中的所有单选钮
$(window.frames[“iframe1”].document).find(“input:radio”).attr(“checked”,”true”);
在IFRAME中操作 选中父窗口中的所有单选钮
(window.parent.document).find(“input:radio”).attr(“checked”,”true”);父窗口想获得IFrame中的Iframe,就再加一个frames子级就行了,如:(window.parent.document).find(“input:radio”).attr(“checked”,”true”);
父窗口想获得IFrame中的Iframe,就再加一个frames子级就行了,如:
(window.frames[“iframe1”].frames[“iframe2”].document).find(“input:radio”).attr(“checked”,”true”);
3.在子窗口中调用父窗口中的另一个子窗口的方法(FRAME):
parent.frames[“Main”].Fun();
注意:建议使用[],这样比较兼容多个浏览器,()火狐/搜狗/谷歌不兼容。
原文来自/article/1251462.html
父中:
<input id="username"type="text" /> <scripttype="text/javascript"> var count = 1; </script>
子iframe中:
<scripttype="text/javascript"> alert(window.parent.count); //获取父中的js变量 alert($("#username", window.parent.document));//获取父中jQuery对象 alert(window.parent.document.getElementByIdx_x('username'));//获取父中DOM对象 </script>
子iframe中(id=”iframeId”name=”iframeName”):
<input id="username"type="text" /> <scripttype="text/javascript"> varcount = 1; </script>
父中:
<scripttype="text/javascript"> alert(document.iframeName.count);//获取子iframe中的js变量 alert($(window.frames["iframeName"].document).contents().find("#username"));//获取子iframe中jQuery对象 alert($("#username",document.frames("iframeName").document));//获取子iframe中jQuery对象 alert(window.document.getElementById('iframeId').contentWindow.document.getElementByIdx_x('username'));//获取子iframe中DOM对象 </script>
收集网上的一些示例:
用jQuery在IFRAME里取得父窗口的某个元素的值
只好用DOM方法与jquery方法结合的方式实现了
在父窗口中操作 选中IFRAME中的所有单选钮
$(window.frames[“iframe1”].document).find(“input:radio”).attr(“checked”,”true”);
在IFRAME中操作 选中父窗口中的所有单选钮
(window.parent.document).find(“input:radio”).attr(“checked”,”true”);父窗口想获得IFrame中的Iframe,就再加一个frames子级就行了,如:(window.parent.document).find(“input:radio”).attr(“checked”,”true”);
父窗口想获得IFrame中的Iframe,就再加一个frames子级就行了,如:
(window.frames[“iframe1”].frames[“iframe2”].document).find(“input:radio”).attr(“checked”,”true”);
3.在子窗口中调用父窗口中的另一个子窗口的方法(FRAME):
parent.frames[“Main”].Fun();
注意:建议使用[],这样比较兼容多个浏览器,()火狐/搜狗/谷歌不兼容。
原文来自/article/1251462.html
相关文章推荐
- 父元素与子iframe相互获取变量和元素对象的具体实现
- 父元素与子iframe相互获取变量和元素对象的具体实现
- 父元素与子iframe相互获取变量和元素对象的具体实现
- 父元素与子iframe相互获取变量和元素对象的具体实现
- 父元素与子iframe相互获取变量和元素对象
- jQuery获取当前点击的对象元素(实现代码)
- js通过元素class名字获取元素集合的具体实现
- js通过元素class名字获取元素集合的具体实现
- js获取对象、数组的实际长度,元素实际个数的实现代码
- jQuery获取当前点击的对象元素(实现代码)
- 扩展jQuery对象时如何扩展成员变量具体怎么实现
- Layer.open 获取子级元素对象或变量
- 快速获取/设置iframe内对象元素的几种js实现方法
- 扩展jQuery对象时如何扩展成员变量具体怎么实现
- jQuery与javascript对照学习 获取父子前后元素 实现代码
- JAXB实现java对象与xml相互转化
- jQuery 练习[二]: 获取对象(3) - 根据属性、内容匹配, 还有表单元素匹配
- Android实现JSON对象获取登录新浪微博
- 简单工厂(Factory)-提供一个创建对象实例的功能,而无须关心其具体实现。被创建实例的类型可以是接口、抽象类,也可以是具体的类。
- ajax实现异步获取数据 (js创建ajax对象)