当前位置: 移动技术网 > IT编程>开发语言>JavaScript > Layer获取iframe的dom元素及调用iframe页的js方法详解

Layer获取iframe的dom元素及调用iframe页的js方法详解

2019年05月17日  | 移动技术网IT编程  | 我要评论

1. 父页面点击第一个按钮触发,获取子页面中的body元素,调用子页面中定义的js方法

yes : function(index,layero){
	//获取iframe的body元素
	var body = layer.getchildframe('body',index);
	//得到iframe页的窗口对象
	var iframewin = window[layero.find('iframe')[0]['name']]; 
	//执行iframe页的showmsg方法
	iframewin.showmsg("mercy");
					
	console.log(iframewin);
	console.log("yes回调函数中:"+body.html());
	console.log(layero,index);
}

2. 子页面定义的showmsg()方法:

<script type="text/javascript">

	function showmsg(msg){
		layer.msg(msg);
	}
</script>

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网