1. 程式人生 > >iframe 獲取父視窗的資料,父視窗獲取iframe的資料

iframe 獲取父視窗的資料,父視窗獲取iframe的資料

1.在父視窗中獲取指定iframe(testiframe) id 為 testid 的class

 程式碼如下 複製程式碼
$(window.frames["testiframe"].document).find("#testid").attr('class');

2.在IFRAME中獲取父視窗中id為testid的class

 程式碼如下 複製程式碼
$(window.parent.document).find("#testid").attr('class');

iframe框架的:

 程式碼如下 複製程式碼

<iframe src="test.html" id="testiframe" width="700" height="300" frameborder="0" scrolling="auto"></iframe>