Jquery对话窗口大小

时间:2011-03-14 16:18:33

标签: jquery-dialog

如何将JQuery对话框大小设置为窗口大小?

我尝试使用'auto',但这只是使它的元素大小,我不想指定px的确切b / c不会是动态的。谢谢!

2 个答案:

答案 0 :(得分:3)

我在这里做了一点猜测,但你可以使用以下方法获得窗口的大小:

var windowWidth = $(window).width();
var windowHeight = $(window).height();

所以,我会接受它,并将该值传递给jQuery对话框。

$( ".dialog" ).dialog({ height: windowHeight, width: windowWidth });

答案 1 :(得分:0)

  

var dlg = $("#dialog"); //获取对话框容器。       //获取窗口尺寸。       var width = $(window).width();       var height = $(window).height();

    // Provide some space between the window edges.
    width = width - 50;
    height = height - 150; // iframe height will need to be even less to account for space taken up by dialog title bar, buttons, etc.

    // Set the iframe height.
    $(dlg.children("iframe").get(0)).css("height", height + "px");

    dlg.dialog({
        modal: true,
        height: "auto", // Set the height to auto so that it grows along with the iframe.
        width: width
    });