根据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) { ...
随机推荐
- 模拟http请求 带 chunked解析办法二
以PHP代码为例 //这个是解析chuned块 get_chunk_data($fsock) { $data = ''; while(true) { $len = hexdec(fgets($fsoc ...
- 【黑金原创教程】【TimeQuest】【第五章】网表质量与外部模型
声明:本文为黑金动力社区(http://www.heijin.org)原创教程,如需转载请注明出处,谢谢! 黑金动力社区2013年原创教程连载计划: http://www.cnblogs.com/al ...
- LeetCode-Combination Sum IV
Given an integer array with all positive numbers and no duplicates, find the number of possible comb ...
- nginx于tomcat项目整合(拆分静态文件)
1.在很多时候我们在网站上应用的时候都会用到nginx,由于我们是java开发者,不可避免的是我们需要在我们的tomcat的工程中应用到nginx,这里的应用可以是请求转发,负载均衡,反向代理,配置虚 ...
- node 同异步处理
同步:序列执行,需等待 异步:非序列执行,无需等待 node同步处理:读取->输出->完毕(队列式执行) node异步处理:读取->完毕(回调输出)(后两步同时进行,谁先到谁先输出) ...
- Oracle Schema Objects(Schema Object Storage And Type)
One characteristic of an RDBMS is the independence of physical data storage from logical data struct ...
- 如何让ios启动画面停留更长时间
几种方法: 方法1:在AppDelegate.m里写上 - (BOOL)application:(UIApplication *)application didFinishLaunchingWithO ...
- linux 将同后缀名的文件统一移至另一个文件夹
w
- HTTP API 设计指南(转)
add by zhj (2014-12-16): 今天才知道,原画HeroKu是国外一个很有名的PaaS提供商,公司很可能会将app迁移到他们那里 英文原文: HTTP API Design Guid ...
- LInux中ThreadInfo中的preempt_count字段
最近看各种上下文,发现和ThreadInfo中的preemption字段密切,于是便调查了下. 看下Linux源码中的注释: /* * We put the hardirq and softirq c ...