使用window.open 实现弹框和居中对齐

    // 打开页面方法
    window.open(url, '_blank', centerStyle('600', '400')+',toolbar=no,menubar=no,resizeable=no,location=no,status=no,scrollbars=yes');

    // 子方法
    var centerStyle = function (height, width) {
        var iTop = (window.screen.height - 30 - height) / 2;       //获得窗口的垂直位置;
        var iLeft = (window.screen.width - 10 - width) / 2;        //获得窗口的水平位置;
        return 'height=' + height + ',width=' + width + ',top=' + iTop + ',left=' + iLeft
    };
posted @ 2019-10-11 15:51  进阶狂热者  阅读(249)  评论(0编辑  收藏  举报