2011-03-14 66 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 
    });