2011-03-14 78 views
2

如何使窗口大小的JQuery对话框大小?jquery对话框窗口大小

我试过使用'auto',但是它只是使它的大小成为它的元素,而我不想指定px的b/c不会是动态的。谢谢!

+0

您正在使用jQuery库或jQuery的UI库,或两者兼而有之? – 2011-03-14 16:21:36

回答

3

我正在猜测一点点在这里,但你可以用得到窗口的大小:

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

所以,我会采取和传递价值的jQuery的对话框。

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

变种DLG = $( “#对话”); //获取对话框容器。 //获取窗口尺寸。 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 
    });