window.open()与window.showModalDialog区别

本文介绍如何在子窗口中调用父窗口的控件或方法。包括使用window.open时的window.opener属性,以及使用showModalDialog时传递父窗口实例进行交互的方式。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

子窗口调用父窗口的东东(控件或者方法):
   1. window.open打开的子窗口有window.opener属性
     子窗口通过window.opener.xxxx获得父窗口的东东。
     如:window.opener.document.getElementById("userName");得到父页面的控件。
       window.opener.fresh();调用父页面的js方法。
   2. window.showModalDialog:不支持window.opener,
      子窗口通过window.dialogArguments.xxxx获得父窗口的东东。
      父窗口通过showModalDialog(url,para,feature)第二个参数para传参数给子窗口,
      子窗口通过window.dialogArguments获得父窗口穿过来的东西。
     
      如:这里传父页面的window过去
        父页面:showModalDialog(url,window,feature)
       子页面:var name = window.dialogArguments.document.getElementById("userName").value;得到父页面的控件。
            var name = window.dialogArguments.fresh();调用父页面的方法。
      这里的window.dialogArguments里的window代表父页面的window,它是通过showModalDialog方法的第二个参数window传过来的,
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值