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
是对当前窗口自身的引用

如:

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

top
返回顶层窗口,即浏览器窗口。

如:

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

parent
返回父窗口

如:

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

opener

opener用于在window.open的页面引用执行该window.open方法的的页面的对象。例如:A页面通过window.open()方法弹出了B页面,在B页面中就可以通过opener来引用A页面,这样就可以通过这个对象来对A页面进行操作。 

如:

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页面跳转 

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

top.document.frames('ifrmMainFrame').location.reload();


转载于:https://my.oschina.net/rouchongzi/blog/111859

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值