对window.open禁用父窗口,并重新启用弹出窗口关闭 [英] disable Parent window on window.open and re enable on close of popup window

查看:900
本文介绍了对window.open禁用父窗口,并重新启用弹出窗口关闭的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在那里我打开一个弹出窗口上点击按钮父窗口:

 功能测试()
    {
            $(机构)追加('< D​​IV ID =modalPopUp级=modalOverlay>');
          变种popupWindow = window.open(Test.aspx文件,'popUpWindow', 'height=300,width=600,left=100,top=30,resizable=No,scrollbars=No,toolbar=no,menubar=no,location=no,directories=no,状态=无');        }

现在我能够打开弹出窗口并关闭父窗口,但现在我要赶关闭按钮,点击+点击弹出窗口弹出事件的外面,所以我可以从我身上卸下ModalPopUp这样我就可以重新eanble父DIV。我如何做到这一点?


解决方案

  1. 您可以使用window.opener对象访问父窗口的弹出窗口,或者:


  2. 您可以从父与popupWindow对象访问子窗口。例如,如果弹出关闭您可以在这样的父窗口unload事件进行注册:

    popupWindow.onunload =函数(){警报('弹出被关闭或重定向')}


I have a parent window where i open up a Popup window on click of a button:

function Test() 
    {
            $("body").append('<div id="modalPopUp" class="modalOverlay">');
          var popupWindow = window.open("test.aspx", 'popUpWindow', 'height=300,width=600,left=100,top=30,resizable=No,scrollbars=No,toolbar=no,menubar=no,location=no,directories=no, status=No');

        }

Right now i am able to open up popup and disable parent window, but now i want to catch close button click + click outside of popup events on Popup window, so i can remove ModalPopUp from my body so i can re eanble parent div. How do i achieve that?

解决方案

  1. You can access the parent window in your popup Window using the window.opener object, or:

  2. You can access the child window from the parent with the popupWindow object. e.g if the popup closes you can register the unload event in your parent window as such:

    popupWindow.onunload = function() { alert('popup was closed or redirected') }

这篇关于对window.open禁用父窗口,并重新启用弹出窗口关闭的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆