我通过确定窗口尺寸,然后相应地设置对话框宽度和iframe高度来实现此目的。下面的代码可能不是最好的,但它可以工作,并且可以很容易地进行修改,使宽度和高度比窗口小百分比。
var dlg = $("#dialog"); // Get the dialog container.
// Get the window dimensions.
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
});