父页面与子页面之间相互操作

父窗口与子窗口、子页面之间相互操作:
iframe:<iframe id="iframeId" name="iframeName" width="100%" src="a.jsp"><form id = "formid"></form></iframe>

父窗口获得子窗口对象并操作子对象:var iframeObj = document.getElementById("iframeId") 或 document.frames["iframeName"]
 iframeObj.src = "a.jsp?random="+Math.random();
 var html = iframeObj.document.getElementById("formid").innerHTML;
父窗口调用子窗口,子窗口执行完毕后,刷新当前父窗口:
 window.location.href=window.location.href;  
 window.location.reload();


子窗口获得父窗口并操作父对象:var parentInputObj = window.parent.document.getElementById("inputId");


子窗口刷新父窗口并关闭子窗口:
    (1)、window.parent.location.href=window.parent.location.href;  
    (2)、window.parent.location.reload();
    window.close();



window.open:var openWindow = window.open('a.jsp?random='+Math.random(),'window','menubar=no,toolbar=no,location=no,directories=no,status=yes,resizable=0,scrollbars=1,width=520,height=150,top=200,left=200');

父窗口获得子窗口对象并操作子对象:openWindow.document.getElementById();


父窗口调用子窗口,子窗口执行完毕后,刷新当前父窗口:
 window.location.href=window.location.href;  
 window.location.reload();


子窗口获得父窗口并操作父对象:var openerInputObj = window.opener.document.getElementById("inputId");


子窗口刷新父窗口并关闭子窗口:
    (1)、window.opener.location.href=window.opener.location.href;  
    (2)、window.opener.location.reload();
    window.close();

window.showModalDialog:var showWindow = window.showModalDialog('a.jsp?random='+Math.random(),window,'dialogwidth=1800px;dialogheight=350px;status:yes;titlebar:no;toolbar:no;scrollbars:yes;resizable:yes;center:yes');

父窗口获得子窗口对象并操作子对象:showWindow.document.getElementById();


父窗口调用子窗口,子窗口执行完毕后,刷新当前父窗口:
 window.location.href=window.location.href;  
 window.location.reload();


子窗口获得父窗口并操作父对象:var parentWindow=window.dialogArguments; 
     var parentInputObj = parentWindow.document.getElementById();


子窗口刷新父窗口并关闭子窗口:
    (1)、parentWindow.location.href=parentWindow.location.href;  
    (2)、parentWindow.location.reload();
    window.close();
 
以上部分整理来源:http://hi.baidu.com/whmtorrent/item/055704be49de189318469704  
 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值