如何关闭多个弹出窗口并返回父窗口

时间:2019-07-18 12:52:44

标签: javascript

我正在尝试关闭多个弹出窗口来解决问题,并且需要一些建议。

单击一个按钮,将打开一个调用URL的弹出窗口,此URL会生成包含内容预览的第二个弹出窗口。

当我单击以关闭第二个弹出窗口时,我希望所有弹出窗口都关闭,并且不做任何刷新就直接返回到父窗口。当前,当第二个弹出窗口关闭时,它将返回到第一个弹出窗口并通过重定向刷新。

单击按钮时调用的函数:

function onPreviewSuccess(data) {
    if (data != "success") {
        _UTL_OpenWindow(data, null, null, "Preview", 800, 600, false);

        return;
    }
}

OpenWIndow函数:

function _UTL_OpenWindow(strURL, strWindowName, nLaunchWidth, nLaunchHeight, strLaunchFeatures) {
    var nScreenWidth = 800;
    var nScreenHeight = 600;
    var nLaunchWidth = 800;
    var nLaunchHeight = 600;

    if (arguments.length < 5) {
        strLaunchFeatures = "notoolbars,resizable=no,scrollbars=yes,";
    }
    else {
        if (strLaunchFeatures.length > 0)
            strLaunchFeatures += ",";
    };

    if (window.screen) {
        nScreenWidth = screen.availWidth - 30;
        nScreenHeight = screen.availHeight - 40;
        nLaunchWidth = Math.min(nLaunchWidth, nScreenWidth);
        nLaunchHeight = Math.min(nLaunchHeight, nScreenHeight);

        //
        // NS/IE switch
        //
        if (window.Event) {
            strLaunchFeatures += 'screenX=' + (nScreenWidth - nLaunchWidth) / 2 + ',screenY=' + (nScreenHeight - nLaunchHeight) / 2 + ',';
        }
        else {
            strLaunchFeatures += 'left=' + (nScreenWidth - nLaunchWidth) / 2 + ',top=' + (nScreenHeight - nLaunchHeight) / 2 + ',';
        }

    }

    strLaunchFeatures += 'width=' + nLaunchWidth + ',height=' + nLaunchHeight;

    window.open(strURL, strWindowName, strLaunchFeatures);
}

我无法控制第二个弹出窗口,因为该弹出窗口是通过_UTL_OpenWindow函数中的“数据”参数调用URL生成的。

有什么主意如何只关闭所有弹出窗口并返回父窗口而不刷新?

谢谢!

0 个答案:

没有答案