Wrox Home  
Search P2P Archive for: Go

  Return to Index  

html_code_clinic thread: RE: html_code_clinic digest: August 21, 2001


Message #1 by Gollwitzer Brian Contr ESC/JS <Brian.Gollwitzer@h...> on Tue, 21 Aug 2001 23:23:31 -0400
In IE you can use...

function calcheight(){

	ourSpan.innerText = ourTable.offsetHeight;
}

I believe offsetHeight gives the correct height
including borders, cellspacing, and cellpadding.

Do a search in Google on offsetHeight and you
should come across a good example on the microsoft
site.

I also suggest getting a copy of MSDN from microsoft.
It is to developers what Technet is to Help Desk people.

They offer it as a free service on their site but
having your own copy installed locally can be much
nicer depending on your internet connection.

-Brian

Subject: Calculate height of dynamic table
From: "Jeremy Wise" <jwise@p...>
Date: Tue, 21 Aug 2001 19:12:17
X-Message-Number: 4

<html>
<head>
<script language="javascript">
function calcheight()
{
	document.all.ourSpan.innerText = document.all.ourTable.height;
}
</script>
</head>
<body onLoad="calcheight();">
	<table id="ourTable" border="1">
		<tr><td>foo</td><td>bar</td></tr>
		<tr><td>baz</td><td>zot</td></tr>
	</table>
	<br>
	Height: <span id="ourSpan">?</span><br>
</body>
</html>

Is there any way to determine the height of this table without setting a 
height="xx" in the <table> tag?  I want to generate a table and then find 
out how many pixels tall it is.  Can I do this with JS/HTML/DHTML/etc?

Thanks!

  Return to Index