2011-03-14 4 views
2

JQuery 대화 상자의 크기를 창 크기로 만들려면 어떻게해야합니까?Jquery 대화 상자 창 크기

'auto'를 사용해 보았습니다.하지만 그 요소의 크기가되고, px가 동적이 아니기 때문에 정확하게 지정하고 싶지는 않습니다. 감사!

+0

당신은 jQuery 라이브러리 또는 JQuery와 UI 라이브러리, 또는 둘 모두를 사용하고 있습니까? –

답변

3

는 여기 추측 약간 데려 갈거야,하지만 당신은 사용하여 윈도우의 크기를 얻을 수 있습니다 :

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

그래서, 나는 그것을 가지고 가고, JQuery와 대화에 그 값을 전달한다.

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

VAR 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 
    });