473,795 Members | 2,839 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 7681
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.getEl ementById) {
cell = document.getEle mentById('aCell ');
}
else if (document.all) {
cell = document.all['aCell'];
}
if (cell) {
alert(cell.offs etWidth + 'x' + cell.offsetHeig ht);
}

--

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***********@l ycos.com (Denzil) wrote in message news:<29******* *************** ****@posting.go ogle.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********@NoS pam.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********@NoS pam.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.getEle mentById("Eleme ntName");
element_name.st yle.height="50p x"

If you then do this:
alert(element_n ame.style.heigh t);
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
10888
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 fixed nor percentage) for this table cell? Sizing the element to 100% width and height does not work, as the parent element's width and height are not specified. And yet, in this case at least, the width and height of the table cell are very...
2
96840
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. Therefore my question is, Is there a CSS attribute I can set on the <TD> tag that will set the size of any text within the table cell?. Regards, Dave
2
6148
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 left cell width is set at 150px The right cell at 100%
11
9487
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 the merged cell the 3 columns above change pixel width. The pixel width still says 200. But the pixel width shown in green above the columns it says 200(172)for example. It seems that the bracketed number is the size the cell displays at rather...
4
16667
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 src=blah.gif width=200 height=200> But, that messes up the aspect ratio, and could size the image larger than it's original size.
3
1892
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 amount of space inbetween the cells, which is making the page entirely too long and/or wide. Can I style these tables in a way that makes the text more compact. Any other advice regarding the tables would be appreciated as well. Thanks in...
0
1183
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 the largest cell in that column? Im using grid layout and when I drag a table to the designer it sets itself to that static size. Also, Im placing a textbox in one of the cells at runtime - how do I set the textbox width to the size of that...
3
4337
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 very efficiently. The tests I have done up to now seem to indicate that each time I update the cell contents (using innerHTML), the entire table is resized and redrawn. This makes my app very slow.
5
3068
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 to change the font size. I tried using the cell's attribute to change the font size. I tried adding a paragraph element and doing the above to it. Removed all font sizes from Body, Table...
4
3197
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 the page speciffically the table cell it is contained within. First i thought that it was just a problem with the images so i just reduced the size of them but now it seems the text is somehow managing to stretch the cell. So i tried limiting...
0
10443
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10165
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10002
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9044
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6783
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5437
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4113
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3728
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2921
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.