博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Jquery:怎样让子窗体的div显示在父窗体之上
阅读量:4451 次
发布时间:2019-06-07

本文共 1892 字,大约阅读时间需要 6 分钟。

<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:

转载于:https://www.cnblogs.com/cxchanpin/p/6852070.html

你可能感兴趣的文章
空指针为什么能调用成员函数?
查看>>
用MySQL的存储过程来实现一些经典函数
查看>>
NOI Linux下Emacs && gdb调试方法
查看>>
React (2) -- State and Lifecycle
查看>>
【转】在EmEditor上编译并运行JAVA
查看>>
关于SqlDateTime溢出的问题
查看>>
jquery下php与ajax的数据交换方式
查看>>
魅蓝Note有几种颜色 魅蓝Note哪个颜色好看
查看>>
使用PullToRefresh实现下拉刷新和上拉加载
查看>>
透明度百分比与十六进制转换
查看>>
HBase表预分区
查看>>
arcgis desktop 10.1 license manager无法启动问题解决
查看>>
django select_related() 联表查询
查看>>
mysql 常用,使用经验
查看>>
NSBundle,UIImage,UIButton的使用
查看>>
vue-cli3 中console.log报错
查看>>
GridView 中Item项居中显示
查看>>
UML类图五种关系与代码的对应关系
查看>>
如何理解作用域
查看>>
从无到满意offer,你需要知道的那些事
查看>>