By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,086 Members | 1,442 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,086 IT Pros & Developers. It's quick & easy.

Resize Window to handle *displayed* elements...

P: n/a
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
Jul 23 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
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>
Jul 23 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.