JS iframe父子頁面元素調用方法 | window parent top opener 解釋

iframe

父窗口調用子窗口 瀏覽器

var hasMore = parent.document.getElementByIdx_x_x_x("hasMore").value;

子窗口調用父窗口
document.frames["ifrmBoxFrame"].me.preLoadBoxGrid();
window.frames["iframe_ID"].document.getElementByIdx_x_x_x("iframe_document_object"-).object_attribute = attribute_value;


window
是對當前窗口自身的引用

如: jsp

window.returnValue = ret;
window.close();

top
返回頂層窗口,即瀏覽器窗口。

如: url

top.frames[tabID].location = url;
top.document.frames("ifrmBoxFrame").me.executeQueryCond();

parent
返回父窗口

如: spa

parent.$("Insheet_FrameTable").src = "";
parent.frames["Insheet_FrameSheetList"].initInsheetList(false);

opener code

opener用於在window.open的頁面引用執行該window.open方法的的頁面的對象。例如:A頁面經過window.open()方法彈出了B頁面,在B頁面中就能夠經過opener來引用A頁面,這樣就能夠經過這個對象來對A頁面進行操做。  htm

如: 對象

var url="editarable.htm?arableID=" + curArableID+"&isDeleteDisabled="+$("Btn_delArable").disabled;
window.open(url, "viewArable", "height=" + h + ",width=" + w + ",left=" + x + ",top=" +y + ",status=no,toolbar=no,menubar=no,location=no");
//第二個頁面中 使用opener
if(!(window.opener==null || window.opener.closed)){
window.opener.me.queryArable();
}
window.close();

首先來講說 parent.window與top.window的用法 
"window.location.href"、"location.href"是本頁面跳轉 
"parent.location.href"是上一層頁面跳轉 
"top.location.href"是最外層的頁面跳轉 
舉例說明: 
若是A,B,C,D都是jsp,D是C的iframe,C是B的iframe,B是A的iframe,若是D中js這樣寫 
"window.location.href"、"location.href":D頁面跳轉 
"parent.location.href":C頁面跳轉 
"top.location.href":A頁面跳轉 
get

parent.frames("frmEletroDocAttachInsert").frames("fraEletroDocAttachView").document.location = "about:blank";

top.document.frames('ifrmMainFrame').location.reload();
相關文章
相關標籤/搜索