根据iframe获取window
今天使用layui弹出窗口,需要将函数写在弹出的窗口,但是按钮事件是在父层窗口绑定的,这样就要在父层窗口调用子层窗口的函数。
子层函数与父层函数
function topup() {
console.log("topup");
}
yes: function(index, layero){
var iframe = layero.find('iframe')[0];
var iframeWin = iframe.contentWindow;
iframeWin.topup();
}
iframe和iframe的关系
首先需要说明的是,w3c已经不推荐使用frame,而推荐使用iframe,iframe也就是inline frame(行内frame),顾名思义它具有css的行内框特性,正是因为这一特性才引出来iframe 高度100%时,出现垂直滚动条
通过window获取iframe
window.frames是个伪数组,可以通过window.frames[index]或window.frames[name]来获取iframe
window.frames[index],索引是从左往右,从上往下的,从0开始,通常我们使用window.frames[name]来获取frame
通过iframe获取window、document
如果想获取iframe里的window或者document,可以使用
iframe.contentWindow、iframe.contentDocument
iframe.contentDocument=iframe.contentWindow.document,不过iframe.contentDocument在IE8及以下的版本不支持。
window获取顶级窗口、父窗口
获取顶级窗口:window.top
获取父级窗口:window.parent
根据iframe获取window的更多相关文章
- html,获取iframe的window,document,自定事件与iframe通信
获取iframe的window对象js代码如下.注意:一定要在文档加载完成之后,才能获取到 var Iframe=document.getElementById("script" ...
- 获取iframe的window对象
在父窗口中获取iframe中的元素 // JS // 方法1: var iframeWindow = window.frames["iframe的name或id"]; iframe ...
- iframe获取元素
原生js在网页中,父元素获取iframe中的元素: window.onload=function () { 例如: console.log(window.frames["iframe的nam ...
- JavaScript---网络编程(6)-Dom和Bom模型概念讲解(节点获取,window对象)
本节讲Dom和Bom模型概念讲解(节点获取,window对象). out.js: 写了2个输出到页面的函数. function println(param){ document.write(param ...
- IFrame与window对象(contentWindow)
ref:http://blog.csdn.net/dongzhiquan/article/details/5851201 var detialIframe=document.all("det ...
- dragable tabs & iframe & new window
dragable tabs & iframe & new window https://www.npmjs.com/package/react-draggable-tab demo h ...
- JQuery获取iframe中window对象的方法-contentWindow
document.getElementsByTagName('iframe')[0].contentWindow 获取到的就是iframe中的window对象.
- javascript获取iframe框架中页面document对象,获取子页面里面的内容,iframe获取父页面的元素,
javascript获取iframe框架中,加载的页面document对象 因为浏览器安全限制,对跨域访问的页面,其document对象无法读取.设置属性 function getDocument(i ...
- JavaScript(Iframe、window.open、window.showModalDialog)父窗口与子窗口之间的操作
一.Iframe 篇 公共部分 //父对象得到子窗口的值 //ObjectID是窗口标识,ContentID是元素ID function GetValue(ObjectID,ContentID) { ...
随机推荐
- 在Eclipse中显示.project和.classpath和.setting目录
在Eclipse中显示.project, .classpath, .gitignore文件和.setting文件夹 在Eclipse中使用git,并显示.gitigonre文件,进行项目管理 在Ecl ...
- org.apache.hadoop.yarn.exceptions.InvalidAuxServiceException: The auxService: mapreduce_shuffle do
在yarn-site.xml 配置文件中增加: <property> <name>yarn.nodemanager.aux-services</name> < ...
- post 与get
GET:从服务器上获取数据,也就是所谓的查,仅仅是获取服务器资源,不进行修改. POST:向服务器提交数据,这就涉及到了数据的更新,也就是更改服务器的数据. 补充: PUT:PUT的英文含义是放置,也 ...
- Boss Group Worker Group NioEventLoopGroup
宜人贷蜂巢API网关技术解密之Netty使用实践 - honeycomb2017的博客 - CSDN博客 https://blog.csdn.net/honeycomb2017/article/det ...
- authz_core_module
w https://httpd.apache.org/docs/trunk/mod/mod_authz_core.html codeigniter index.html .htaccess <I ...
- TCP implements its own acknowledgment scheme to guarantee successful data delivery
wTCP本身已经确保传输的成功性. HTTP The Definitive Guide 4.2.4 Delayed Acknowledgments Because the Internet itsel ...
- multi-paradigm
w范式 https://developer.mozilla.org/en-US/docs/Web/JavaScript https://developer.mozilla.org/zh-CN/docs ...
- 关于一个非常非常无语的bug,与君共勉
今天,哦,不对,是昨天晚上,我花了大概四十分钟去找一个bug,结果还没找到 错误代码" $('#sendAreaInfo').citypicker('reset'); $('#sendAre ...
- 【转】通过ionice和nice降低shell脚本运行的优先级
对于一些运行时会造成系统满载的脚本, 例如数据库备份, 会影响当时其他服务的响应速度, 可以通过ionice和nice对其IO优先级和CPU优先级进行调整例如降低"/usr/local/bi ...
- ICO成本价
[当前ICO成本价]仅供参考:ICOcoin 成本价1元SNT 成本价0.26元UGT 成本价2.7元PAY 成本价6元OMG 成本价2.6元YOYO 成本价 0.17元BNT 成本价26元BAT 成 ...