Jquery:怎样让子窗体的div显示在父窗体之上
<1> js或者jQuery訪问页面中的框架iframe.
注意:框架内的页面是不能跨域的! 如果有两个页面,在同样域下.
如果:父窗体 index.html ,有id 为 subifrm 的iframe
1. 在index.html运行JS直接訪问子窗体中某元素:
document.getElementById('subifrm').contentWindow.document.getElementById('test').style.color='red'
2. 利用jquery 来訪问子窗体
$("#subifrm").contents().find("#test").css('color','red');
====================================================================
====================================================================
<2> 用DOM方法与jquery方法结合的方式实现互动操作
1.在父窗体中操作 选中IFRAME中的全部单选钮
$(window.frames["iframe1"].document).find("input[@type='radio']").attr("checked","true");
2.在IFRAME中操作 选中父窗体中的全部单选钮
$(window.parent.document).find("input[@type='radio']").attr("checked","true");
====================================================================
====================================================================
<3> 使用jquery操作iframe
1 页面里有两个ifame
<iframe id="leftiframe"></iframe>
<iframe id="mainiframe></iframe>
<iframe id="leftiframe"></iframe>
<iframe id="mainiframe></iframe>
leftiframe中jQuery改变mainiframe的src代码:
1
$("#mainframe",parent.document.body).attr("src","")
2、 假设内容里面有一个ID为mainiframe的ifame
<iframe id="mainifame"></ifame>
<iframe id="mainifame"></ifame>
ifame包括一个someID
<div id="someID">you want to get this content</div>
<div id="someID">you want to get this content</div>
得到someID的内容
$("#mainiframe").contents().find("someID").html();或者$("#mainiframe").contains().find("someID").text();
$("#mainiframe").contents().find("someID").html();或者$("#mainiframe").contains().find("someID").text();
$("#mainiframe").contents().find("someID").html();或者$("#mainiframe").contains().find("someID").text();
2 、如上面所看到的
leftiframe中的jQuery操作mainiframe的内容someID的内容
$("#mainframe",parent.document.body).contents().find("someID").html();或者$("#mainframe",parent.document.body).contents().find("someID").val();
source:
最新文章
- UVA 558 判定负环,spfa模板题
- Oracle 分组聚合二种写法,listagg和wmsys.wm_concat
- HTML,XML中的转义字符
- GDB下查看内存命令(x命令)
- Bluebird-Core API (三)
- 为Eclipse设置背景色
- [Codeforces667A]Pouring Rain(数学,几何)
- OpenNebula Restfull 接口请求示例
- 关于.net中的脚本语言使用
- Strategy 模式
- C++中模板类使用友元模板函数
- hdu 4983 Goffi and GCD(欧拉函数)
- 在VirtualBox安装OS X 10.10
- linux 标准目录
- Java学习笔记——排序算法之希尔排序(Shell Sort)
- C#中MessageBox.Show()方法详解
- 參与 Spring 4 中文文档翻译
- 发布iOS应用时,Xcode报错:Application failed codesign verification.
- 意外的php之学习笔记
- Vue Element使用icon图标(第三方)