iframe的子/父页面间通信

父页面方法:

function setDataToChirld(){
	alert("我是父页面的方法");
}

子页面方法:

function getPre_retentionTax(){
	parent.window.setDataToChirld();
}

子页面方法触发方式:

	<div class="form-group">
	   <label class="col-sm-2 control-label ali-center left-label">税务产生时间:</label>
	   <div class="col-sm-10">
	     <input id="createTime" name="createTime" class="form-control"  type="date" onchange="getPre_retentionTax()">
           </div>
	</div>

效果:当子页面选择的税务产生时间项产生变化后触发“getPre_retentionTax()”方法,在该方法中调用父类的方法“setDataToChirld”,打印出语句“我是父页面的方法”。

猜你喜欢

转载自blog.csdn.net/txd2016_5_11/article/details/83213633