【问题标题】:Auto Resize IE modal dialog based on the content changes根据内容更改自动调整 IE 模态对话框的大小
【发布时间】:2013-11-20 03:56:32
【问题描述】:
使用浏览器:IE 9
我正在使用 window.showModalDialog() 函数打开一个 IE 模式对话框。
当对话框打开时,我使用 dialogHeight 和 dialogWidth 属性提供高度和宽度。这很好用。
但要求是当对话框的内容发生变化时,我想调整对话框的高度。
最初,对话框中隐藏了某些元素,由于对话框中的垂直滚动条,这些元素将在用户操作时可见,以避免我想调整对话框高度的大小。
请提出建议。
谢谢,
阿米特
【问题讨论】:
标签:
jquery
dialog
modal-dialog
internet-explorer-9
showmodaldialog
【解决方案1】:
您可以在打开模式对话框的页面中调整大小。例如,看下面的代码:
t3.html
<!DOCTYPE HTML>
<html>
<head>
<title>test</title>
</head>
<body>
test<br>
test adjust<br>
test adjust<br><br>
<script language=javascript>
function adjustDialog() {
window.dialogHeight = 400+'px';
window.dialogWidth = 400+'px';
}
</script>
<button onclick="adjustDialog();">Adjust me</button>
</body>
</html>
t4.html
<!DOCTYPE HTML>
<html>
<head>
<title>test</title>
</head>
<body>
<script language=javascript>
window.showModalDialog("t3.html","Dialog Box","dialogHeight: 300px; dialogWidth: 300px; dialogTop: 250px; dialogLeft: 300px; edge: Sunken; center: No; help: No; resizable: No; status: No;");
</script>
</body>
</html>
打开t4.html,弹出一个模态对话框,点击里面的按钮,可以调整对话框。