2

我正在使用这样的 JQuery UI 对话框;

 $(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);
    }

对话框已打开页面的中心,但弹出窗口出现不同的坐标。我想重叠。这该怎么做?

4

1 回答 1

2

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

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);
}
于 2012-04-30T07:45:55.603 回答