js:一个页面如何获取一个IFrame页面中的字段值。

一个页面如何获取一个IFrame页面中的字段值。
 
如:
a.html
页面的js如下:
<IFRAME ID="offer" name="offer" src="'+url+'" frameborder="no" style="padding: 0px; width: 100%; height: 750px;"></IFRAME>
嵌套了一个offer的页面。offer页面中有个文本框,id是offerId。
那我如何取获取offerId的value呢?
 
解决方法:
var offerId = $(document.getElementById('offer').contentWindow.document.getElementById("offerId")).html();//套餐id
格式:
$(document.getElementById('iframe框架的id').contentWindow.document.getElementById("文本框id")).html();
 

猜你喜欢

转载自www.cnblogs.com/lirenzhujiu/p/9724305.html