473,387 Members | 1,597 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

get the size of a table or cell

is there a way by using html or javascript or anything else for that matter
to detirmine the actual height or width of a table or cell

for example if i only set the height to 100 and the data in the cell needs a
higher cell it expands to suit - i want to find out what the actual height
ends up ??

thanks for your help

chris
Jul 23 '05 #1
6 7646
chris wrote:
is there a way by using html or javascript or anything else for that matter
to detirmine the actual height or width of a table or cell

for example if i only set the height to 100
Make sure you tell it if this is 100 PIXELS (px), PERCENT (%) etc...
This is important!

and the data in the cell needs a higher cell it expands to suit - i want to find out what the actual height
ends up ??

thanks for your help

chris


No, not that I know of, sorry. Annoying, isn't it?

Just work around it; use good code, learn CSS (http://www.webmonkey.com)
and you can have per-pixel accuracy over your pages anyway.
Jul 23 '05 #2


chris wrote:
is there a way by using html or javascript or anything else for that matter
to detirmine the actual height or width of a table or cell

for example if i only set the height to 100 and the data in the cell needs a
higher cell it expands to suit - i want to find out what the actual height
ends up ??


Most browsers (Netscape 6/7, Mozilla, IE 4/5/6, Opera 7 for sure) allow
you to read the offsetWidth/offsetHeight of an element e.g.
<td id="aCell">...</td>

var cell;
if (document.getElementById) {
cell = document.getElementById('aCell');
}
else if (document.all) {
cell = document.all['aCell'];
}
if (cell) {
alert(cell.offsetWidth + 'x' + cell.offsetHeight);
}

--

Martin Honnen
http://JavaScript.FAQTs.com/

Jul 23 '05 #3
"chris" wrote in message news:
is there a way by using html or javascript or anything else for that matter
to detirmine the actual height or width of a table or cell


Hi,

The following link from MSDN gives all the DHTML Object Model
properties that are related to the dimension and location of elements.
Worth a see.

[Measuring Element Dimension and Location]
http://msdn.microsoft.com/library/de...ientheight.asp

Cheerz,
Denzil
Jul 23 '05 #4
de***********@lycos.com (Denzil) wrote in message news:<29**************************@posting.google. com>...
The following link from MSDN gives all the DHTML Object Model
properties that are related to the dimension and location of elements.
Worth a see.

[Measuring Element Dimension and Location]
http://msdn.microsoft.com/library/de...ientheight.asp


This is the link - [Measuring Element Dimension and Location]
http://msdn.microsoft.com/library/de.../measuring.asp

Cheerz,
Denzil
Jul 23 '05 #5

"Will Gittoes" <As********@NoSpam.org> skrev i en meddelelse
news:1092735001.91079@ftpsrv1...
chris wrote:
is there a way by using html or javascript or anything else for that matter to detirmine the actual height or width of a table or cell

for example if i only set the height to 100


Make sure you tell it if this is 100 PIXELS (px), PERCENT (%) etc...
This is important!

and the data in the cell needs a
higher cell it expands to suit - i want to find out what the actual height ends up ??

thanks for your help

chris


No, not that I know of, sorry. Annoying, isn't it?


Actually, if you can set a property, then you can also read a property.
Anything else wouldn't make much sense.

Robert
Jul 23 '05 #6
noone wrote:
"Will Gittoes" <As********@NoSpam.org> skrev i en meddelelse
news:1092735001.91079@ftpsrv1...
chris wrote:
is there a way by using html or javascript or anything else for that
matter
to detirmine the actual height or width of a table or cell

for example if i only set the height to 100


Make sure you tell it if this is 100 PIXELS (px), PERCENT (%) etc...
This is important!

and the data in the cell needs a
higher cell it expands to suit - i want to find out what the actual
height
ends up ??

thanks for your help

chris


No, not that I know of, sorry. Annoying, isn't it?

Actually, if you can set a property, then you can also read a property.
Anything else wouldn't make much sense.

Robert


But that merely reads back the property you set!

If you did something in Javascript such as:
element_name = document.getElementById("ElementName");
element_name.style.height="50px"

If you then do this:
alert(element_name.style.height);
You will get 50px - no matter WHAT size it has actually been rendered
(i.e. not taking into account a giant image in the element etc.).
Jul 23 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Thomas Mlynarczyk | last post by:
Hello, How can I make an <a> element (containing text only, styled to be a box with a border) as big as the table cell in which it resides, *without* having specified any width/height (neither...
2
by: Dave Moore | last post by:
Hi, I want to use CSS to define the font size in every cell of a table. This avoids needing to define the font size in every <TD> tag using the normal multiple HTML <FONT SIZE="2"> notation....
2
by: DaveO | last post by:
OK. Now I'm all googled out and still puzzled ! I admit I am very new to javascript, but think that it is the only solution to this. I have a web page with a table ( 2 columns, 1 row ) The...
11
by: SarahMarsden | last post by:
I'm new to Dreamweaver (using MX 2004). I have a 2 row 3 column table. I have set each column to 200 pixels. The second row I have merged into one cell. When I enter text (or anything else) into...
4
by: no-spam | last post by:
Hello, I have an HTML question that I'm not sure can be solved. I want to restrict the maximum size of an inline image. For example, I can force the image to be 200x200 if I do this: <img...
3
by: gscott66 | last post by:
Hello, I am fairly new to design and in particular CSS. I have a site with two tables that I cannot seem to get sized correctly. When you view the link, you'll notice that there is a tremendous...
0
by: Grant | last post by:
Gday, Im using C# in a web solution. Ive placed a WebControls.Table on my webform and am building rows and cells during runtime. How do I dynamically set the column width of the table according to...
3
by: patl | last post by:
Hi all, I am trying to write a terminal emulator using Javascript + AJAX and I need to create an 80x25 table (each cell contains 1 character) in which I can update the contents of each cell...
5
by: _Who | last post by:
I spent all day yesterday trying different things. Something has happened so I can't change font size. I have a table and in the first cell I have only text. I tried using the cell's Style...
4
by: chazzy69 | last post by:
The problem is as follows, i am inputing text and images from another source via my php script, now when i try to display the text and images into a page of my own styling the text and images skewed...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.