...

View Full Version : setting a minimum size for a modal dialog



davidklonski
06-27-2004, 06:21 PM
Hi people

I am using window.showModalDialog() to open a modal dialog window.
I would like to set a minimum size for the window (width & height).

I set the following:


<body onresize="pageResize()">
...
</body>

In a javascript file I have:


function pageResize() {
var windowWidth = document.body.clientWidth;
var windowHeight = document.body.clientHeight;

if (windowWidth < 100) {
document.body.clientWidth = 100;
}
if (windowHeight < 100) {
document.body.clientHeight = 100;
}
}

I get an error saying: "Object doesn't support this action" for line settings:


document.body.clientWidth = 100;


Is there another way of doing that?

thanks in advance

neofibril
06-28-2004, 11:20 AM
Properties such as clientWidth are read-only.

If I recall correctly, once opened, the width and height properties of an html dialog can only be modified from an html application.

They can be set initially in the showModalDialog call, however.

davidklonski
06-28-2004, 01:10 PM
I solved the problem.
Taken from the MSDN library (concerning the usage of resizeTo):


This method does not work on dialog windows. In order to move or size a dialog window, manipulate the dialogHeight, dialogWidth, dialogTop, and dialogLeft properties.

This is my final solution:


function pageResize() {
var currentHeight = 0;

// the frames are set one on top of the other - so I am calculating the total height
for (i=0; i<parent.frames.length; i++) {
currentHeight += parent.frames[i].document.body.clientHeight;
}
var currentWidth = parent.frames[0].document.body.clientWidth;

if (currentWidth < 300) {
parent.dialogWidth = "300px";
}
if (currentHeight < 300) {
parent.dialogHeight = "300px";
}
}



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum