jQuery:有没有办法将Jquery UI对话框最大化到浏览器大小?

时间:2011-03-01 09:52:49

标签: jquery jquery-ui

有没有办法将Jquery UI对话框最大化到浏览器大小(最大宽度/高度)?

更新

我使用this question的答案来获取浏览器的高度和宽度,并设置对话框的高度和宽度属性。

2 个答案:

答案 0 :(得分:1)

Looking at the manual,您需要使用heightwidthmaxHeightmaxWidth个属性。要将其调整为任何浏览器窗口大小,您必须通过单击手册上的resize选项卡来使用可以看到的events事件。

答案 1 :(得分:1)

var isFullScreen = false;

function toggleFullScreen() {

    var windowW = $(window).width();
    var windowH = $(window).height();

    if (!isFullScreen) {

        //view full screen mode
        var wFull = windowW - 100;
        var hFull = windowH - 100;

        var xLeft = parseInt((windowW / 2) - (wFull / 2));
        var yTop = parseInt((windowH / 2) - (hFull / 2));     

        if (dialog != null) {
            dialog.dialog('option' , 'width', wFull);
            dialog.dialog('option' , 'height', hFull);    
            dialog.dialog('option', 'position', [xLeft,yTop]);
        }

        isFullScreen = true;

    } else {

        //view normal/original size mode
        //use the "dafault" height and width
        var xLeft = parseInt((windowW / 2) - (300 / 2));
        var yTop = parseInt((windowH / 2) - (200 / 2));

        if (dialog != null) {
            dialog.dialog('option' , 'width', 300);
            dialog.dialog('option' , 'height', 200);    
            dialog.dialog('option', 'position', [xLeft,yTop]);
        }

        isFullScreen = false;
    }
}