Resize Window to handle *displayed* elements...

S

SPG

Hi,

Please diregard my previous post...

I have found out that doing a window.resizeTo(w,h) does not resize the
client area tot his size, but the entire window (including tool bars etc).

So, with an address bar, a tool bar and a status bar etc showing, the
window.document.body.offsetHeight value will be ~200 points smaller than the
required size.

We have a simple set of data in a table, but it can resize based on a font
size.
On change of font from a combo we call a resize function.

How can I ensure that the body.offsetHeight and widths are enough to show
all of my table, without hard coding for toolbars etc (Because they may not
be there on some browsers.)

Is there a way like in java to *pack* the client area to best fit?

Steve
 
S

SPG

And here is a bit of sample code..

<html>
<head>

<script language="javascript">
function reSizeWindow()
{
var winHeightOffset = 25; //We seem to need to add this to make the screen
fit..??
var iHeight;
var iWidth;
var iMaxIGSCompositeHeight;
var iMenuHeight=0;

iWidth = 680;
iMaxIGSCompositeHeight = 580;

var oTableW;
var oTableH;
var oTableMenu = document.getElementById('tMenu');
if( oTableMenu !=null)
{
iMenuHeight = oTableMenu.offsetHeight;
}

oTableW = window.tblMain;
oTableH = oTableW;

try
{
var tH = oTableH.offsetHeight;
var menuH = oTableMenu.offsetHeight;
iHeight = tH + menuH + winHeightOffset;
iWidth = window.document.body.offsetWidth;
window.resizeTo(iWidth, iHeight);
alert("DONE: New Height: " + iHeight + ", Window Height: " +
window.document.body.offsetHeight );

}
catch(e)
{
alert(e);
}

}
</script>
</head>
<body>
<table border=1 id="tMenu">
<tr><td><a onclick="reSizeWindow()">Resize</a></td></tr>
</table>
<table border=1 id="tblMain">
<tr>
<td>a</td>
</tr>
<tr>
<td>a</td>
</tr>
<tr>
<td>a</td>
</tr>
<tr>
<td>a</td>
</tr>
<tr>
<td>a</td>
</tr>
<tr>
<td>a</td>
</tr>
<tr>
<td>a</td>
</tr>
<tr>
<td>a</td>
</tr>
</table>
</body>
</html>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,819
Latest member
masterdaster

Latest Threads

Top