Javascript 设置窗口弹出窗口坐标

Javascript 设置窗口弹出窗口坐标,javascript,jquery,jquery-ui,jquery-ui-dialog,Javascript,Jquery,Jquery Ui,Jquery Ui Dialog,我像这样使用jQueryUI对话框 $(function () { var dlg = $("#dialog").dialog({ draggable: true, resizable: false, width: 950, height: 480, autoOpen: false, modal: true, m

我像这样使用jQueryUI对话框

 $(function () {
        var dlg = $("#dialog").dialog({
            draggable: true,
            resizable: false,
            width: 950,
            height: 480,
            autoOpen: false,
            modal: true,
            minHeight: 30,
            minwidth: 30,
            title: 'test'
        });
    });
窗口:

    function PopupUrl(url, name, width, height) {
        var features = "location=1, status=1, scrollbars=1, width=" + width + ", height=" + height + '"';
        window.open(url, name, features);
    }

对话框被打开页面的中心,但弹出窗口显示不同的坐标。我想谈谈。如何做到这一点?

只需在功能列表中添加一个计算出的顶部和左侧,弹出窗口将位于屏幕中央:

function PopupUrl(url, name, width, height) {
    var top = parseInt((screen.availHeight / 2) - (height / 2));
    var left = parseInt((screen.availWidth / 2) - (width / 2));
    var features = "location=1, status=1, scrollbars=1, width=" + width + ", height=" + height + ", top=" + top + ", left=" + left;
    window.open(url, name, features);
}