JQuery iframe
子页面获取父页面的元素
function colisetapTJ() { var tapid = $('div:contains("添加档案报送"):last', window.parent.document).attr("id"); var deleteid = tapid.substring(7, tapid.length); var id = "img" + deleteid; var sdfsdd = $("#" + id + "", parent.document).parent().click(); }
iframe页面调用同级iframe页面元素
function colisetapTJ() { var tapid = $('div:contains("添加档案报送单"):last', window.parent.document).attr("id"); var deleteid = tapid.substring(7, tapid.length); var id = "img" + deleteid; var tapda = $('div:contains("档案报送"):eq(4)', window.parent.document).attr("id"); var tadid = tapda.substring(7, tapda.length); var Iframe = "Iframe" + tadid; var frameObj = parent.document.getElementById("" + Iframe + "");
//contentWindow 兼容各个浏览器,可取得子窗口的 window 对象。 frameObj.contentWindow.document.getElementById("btnSearch").click(); $("#" + id + "", parent.document).parent().click(); }
iframe 父页面调取子页面元素
window.frames["myiframeA"].document.getElementById('hello').style.background = "red";
//父取子
var $Adthumb = $("#xmqk").contents().find(".ad-thumb-list li a").length;
//子取父
$('#hiddenviews', window.parent.document).val('false');