js:window.showModalDialog模态窗口小小的用一下

js实现在父窗口打开子窗口,子窗口获取父窗口数据,

格式:window.showModalDialog(url,window,'dialogwidth=1800px;dialogheight=350px;status:yes;titlebar:no;toolbar:no;scrollbars:yes;resizable:yes;center:yes');

实例描述:在主表单中,嵌入一个iframe,通过iframe里面的按钮打开子窗口,在子窗口中获取主表单数据

例如:window.showModalDialog(

‘index.jsp?id=’+id,

window,

'dialogwidth=1800px;dialogheight=350px;status:yes;titlebar:no;toolbar:no;scrollbars:yes;resizable:yes;center:yes');

在子窗口中,获取父窗口的对象以及数据:子窗口的上一级父窗口为iframe,而主表单为上两级窗口,所以要用到parent

var parentObj = window.dialogArguments;  //传递的window就代表父窗口对象

var val = parentObj .parent.document.getElementById("id").value;
如果只有一级:var val = parentObj .document.getElementById("id").value;
     parentObj.document.location.href= parentObj.document.location.href;  //刷新父窗口
              this.close();//关闭当前子窗口


而url传递的参数可以通过var   str   =  window.location.href;获取的字符串进行解析获得



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值