Check if a popup window is closed

后端 未结 4 1323
旧巷少年郎
旧巷少年郎 2020-11-29 11:34

I am opening a popup window with

var popup = window.open(\'...\', \'...\');

This javascript is defined in a control. This control is then

4条回答
  •  粉色の甜心
    2020-11-29 11:45

    Ok so what you do is as follows.

    create a method "setWindowObjectInParent" then call that in the popup. var popupwindow;

    function setWindowObjectInParent(obj)
    {
    popupwindow = obj;
    }
    

    Now you have an object that you can call focus on.

    So in the popup add

    $(window).unload(function(){
    window.opener.setWindowObjectInParent();
    });
    window.opener.setWindowObjectInParent(window);
    

    This will unset the obj when the popup is closed and set the object when it is opened.

    Thus you can check if your popup is defined and then call focus.

提交回复
热议问题