如何修复父窗口的窗口?

时间:2018-05-29 08:08:05

标签: javascript html window.open

如何将弹出窗口(window.open())修复到父窗口?当我点击另一个标签时,我的窗口丢失了。

function popitup(url, w, h) {

    var dualScreenLeft = window.screenLeft != undefined ? window.screenLeft : window.screenX;
    var dualScreenTop = window.screenTop != undefined ? window.screenTop : window.screenY;

    var width = window.innerWidth ? window.innerWidth : document.documentElement.clientWidth ? document.documentElement.clientWidth : screen.width;
    var height = window.innerHeight ? window.innerHeight : document.documentElement.clientHeight ? document.documentElement.clientHeight : screen.height;

    var left = ((width / 2) - (w / 2)) + dualScreenLeft;
    var top = ((height / 2) - (h / 2)) + dualScreenTop;

    popupWindow = window.open(url, title,"resizeable=yes,location=no,width=" + w + ", height=" + h + ",top=" + top + ",left=" + left + ", overflow-x=hidden");

    popupWindow.pw = pw;

    if (window.focus) {
        popupWindow.focus()
    }
    return false;
}

1 个答案:

答案 0 :(得分:0)

如果您想要将弹出窗口附加到页面上,请不要使用弹出窗口;在页面中使用绝对定位的元素(例如,div)并将相关的HTML加载到div