JS 打开、关闭子窗口

JS 打开、关闭子窗口

var win;
function openChildWin(){
    var screenX = typeof window.screenX != 'undefined' ? window.screenX : window.screenLeft,
        screenY = typeof window.screenY != 'undefined' ? window.screenY : window.screenTop,
        outerWidth = typeof window.outerWidth != 'undefined' ? window.outerWidth : document.body.clientWidth,
         outerHeight = typeof window.outerHeight != 'undefined' ? window.outerHeight : (document.body.clientHeight - 22),
         width = 680,
         height = 480,
         left = parseInt(screenX + ((outerWidth - width) / 2), 10),
         top = parseInt(screenY + ((outerHeight - height) / 2.5), 10),
         features = (
                'width=' + width +
                ',height=' + height +
                ',left=' + left +
                ',top=' + top);
    win = window.open('/login', 'Connect with facebook', features);
    if (window.focus) {win.focus();}
}

function closeChildWin(){
    if(win && win.open && !win.closed){
        win.close();
    }
}

你可能感兴趣的:(JavaScript)