iframe子页面调用父页面全局变量的方法


将父iframe中的全局变量赋值给主html

子iframe再从主html中得到该值。


 

主html:

stcc.html   

 var weaList = [];

父iframe:

WeatherMsg.html

全局变量:

var weatherNum_send = [];

获取weatherNum_send 的值:

	var len=$('table tbody tr').length;
	var totalNum=0;
	for(var i=0; i<len;i++){
   	 	if( $('table tbody tr').eq(i).find('input').is(":checked")){
   	 		weatherNum_send[totalNum] = weatherNum_list[i];
   	 		totalNum++;
   	 	}
	}

 赋值给stcc.html的变量:

parent.weaList=weatherNum_send; 

子iframe:

WeatherInfoToShip.html

直接使用parent.weaList:

msg.weatherNum[i]=parent.weaList[i];

  

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM