...

View Full Version : Making a window modal



sms9z
07-24-2002, 04:55 PM
Does anyone know how I can bring up a modal window with a webpage that can control the size of the window? I have a webpage that uses javascript to resize itself but when I bring it up using showModalDialog the page doesn't resize itself.

My objective is to bring up a page in a window that is modal but the window should be of specific size that can be controlled by the page that is being loaded and not by the page the page that is opening the modal window.

I hope I have explained my problem well. I would appreciate a quick reply. Thanks everybody.

KrazyKid
07-24-2002, 07:39 PM
Make two files...

//start showModalChangeBrowserSize.html//
<html>
<head>
<SCRIPT>
<!--
function doModal(url){
var strWindowSize=showModalDialog(url,0,'dialogWidth:300px;dialogHeight:200px;resizable:yes;status:no');
if (strWindowSize == -1 || strWindowSize == null)
{
alert('You clicked cancel or the close box');
document.forms.frmModalTest.btnShowModal.value = 'Cancelled!';
}
if ((strWindowSize != -1) && (strWindowSize != ''))
{
//document.forms.frmModalTest.btnShowModal.value = strWindowSize;
switch(strWindowSize)
{
case "640":

window.resizeTo("640", "480");
break;
case "1280":
window.resizeTo("1280", "1024");
break;
default:
break;
}

}
else
{
document.forms.frmModalTest.btnShowModal.value = 'Cancelled!';
}
}
-->
</SCRIPT>
<body>
<form name="frmModalTest">
<input type="button" name="btnShowModal" value="Show Modal Window To Change This Window Size" onclick="doModal('ShowModalWindow.html')">
</form>
</body>
</html>
//end showModalChangeBrowserSize.html//

//start ShowModalWindow.html//
<HTML>
<HEAD>
<Title>Select Screen Size</Title>
<SCRIPT>
<!--
function doOK()
{
window.returnValue=selChangeSize.value;
window.close()
}

function doCancel()
{
// return a special known value if the user chooses cancel
window.returnValue=-1;
window.close();
}
-->
</SCRIPT>
</head>
<BODY>
Select The Values to change the Parent Window Size:
<br>
<select name="selChangeSize">
<option value="640">640X480</option>
<option value="1280">1280X1024</option>
</select>
<P><INPUT type=button onclick="doOK()" value=OK>&nbsp;
<INPUT type=button onclick="doCancel()" value=Cancel></P>
</BODY>
</HTML>
//ShowModalWindow.html//

Hope that helps!

Mrs G
07-24-2002, 07:40 PM
You could try the following:


<SCRIPT LANGUAGE=JavaScript>
window.resizeTo(600,400)
</SCRIPT>


This script would have to be placed in every page that was loaded into the window that requires a different window size.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum