JQuery/JS获取iframe(父、子)页面元素
var tbl = $("#Iframe").contents().find('body table.mTable');tbl.find('tr:eq(9) td:eq(3) input').val(comment.Name);tbl.find('tr:eq(9) td:eq(5) input').val(comment.Sex);
·
JQuery
1、从父页面中获取iframe页面中的元素:
方法1:$(window.frames["父页面中iframe的id属性值"].document).find("#iframe中的控件ID");
方法2:$("#iframe的ID").contents().find("#iframe中的控件ID");
方法3:$("#iframe中的控件ID",document.frames("frame的name").document);
2、从iframe中获取父页面中的元素:
方法1:$(window.parent.document).find("父页面中元素的id属性值");
方法2:$('#父窗口中的元素ID', parent.document);
JS
1、从父页面中获取iframe页面中的元素:
方法1:window.frames["iframe的name值"].document.getElementById("iframe中控件的ID");
方法2:var obj=document.getElementById("iframe的name").contentWindow;
var ifmObj=obj.document.getElementById("iframe中控件的ID");
2、从iframe中获取父页面中的元素:
window.parent.document.getElementById("父窗口的元素ID");
更多推荐
已为社区贡献2条内容
所有评论(0)