473,698 Members | 2,602 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Identifying width of a table

I have a page with multiple tables, some of which have the class
"ClassA".

I need to identify the widest table whose class is ClassA.

The following JavaScript code returns the table width
("thisTableWidt h")
when run in FireFox 2.0, but returns '0' when run in IE6.

Be grateful for any advice for how to get at this value using IE6.

Thanks

Griff
-----------------------------
var thisTableWidth = 0;
var maxTableWidth = 0;

// Get collection of tables
var eachObject = document.getEle mentsByTagName( "table");

// Iterate through each table
for (var i = 0; i < eachObject.leng th; i++)
{
// Does this table have a class called ClassA?
if (eachObject[i].className.inde xOf('ClassA') != -1)
{
// Attempt to read this table's width
thisTableWidth = eachObject[i].offsetWidth;

// Is this wider than my last table I checked?
if (thisTableWidth maxTableWidth)
{
maxTableWidth = thisTableWidth;
}
}
}
-----------------------------
PS - also posted to [microsoft.publi c.scripting.jsc ript]

May 9 '07 #1
2 1234
Found it out...

In IE, the JavaScript is run BEFORE the objects are displayed,
therefore they have a width of 0.

Have to put the Js in a function and call it in the onLoad() page
event.

May 9 '07 #2
I don't know if this may be of any relevance to you, but it was useful
to me not so long ago.

http://blogs.wdevs.com/ramavavilala/.../22/13623.aspx

-yanick
On 9 mai, 11:07, Griff <griffithsj_... @hotmail.comwro te:
I have a page with multiple tables, some of which have the class
"ClassA".

I need to identify the widest table whose class is ClassA.

The following JavaScript code returns the table width
("thisTableWidt h")
when run in FireFox 2.0, but returns '0' when run in IE6.

Be grateful for any advice for how to get at this value using IE6.

Thanks

Griff
-----------------------------
var thisTableWidth = 0;
var maxTableWidth = 0;

// Get collection of tables
var eachObject = document.getEle mentsByTagName( "table");

// Iterate through each table
for (var i = 0; i < eachObject.leng th; i++)
{
// Does this table have a class called ClassA?
if (eachObject[i].className.inde xOf('ClassA') != -1)
{
// Attempt to read this table's width
thisTableWidth = eachObject[i].offsetWidth;

// Is this wider than my last table I checked?
if (thisTableWidth maxTableWidth)
{
maxTableWidth = thisTableWidth;
}
}
}
-----------------------------
PS - also posted to [microsoft.publi c.scripting.jsc ript]
May 9 '07 #3

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

Similar topics

7
12213
by: Graham J | last post by:
Apologies for the partial post that mysteriously escaped as I was composing. I shall try again. For many years I have been happily and successfully coding tables such that the WIDTH specified in a TD is the complete column width including any CELLPADDING. For example for a 400 pixel wide table with four 100 pixel wide columns and 10 pixel cellpadding... <TABLE WIDTH="400" BORDER="0" CELLSPACING="0" CELLPADDING="10">
4
26208
by: N. Demos | last post by:
The following code renders as intended in IE (A TABLE, with cells of fixed width and height, inside of a DIV with fixed width and height and overflow set to hidden.) In Firefox, the table cells assume a narrower with than specified. If I comment out the width for the DIV, then the cells render with the correct width and height. Why is this happening? Thanks. Regards, N. Demos
0
3067
by: javaguy | last post by:
I have a table I hide show/hide through a pair of divs. The show/hide part works fine in both Mozilla and MSIE. When switching between the hide and show versions the Mozilla browser keeps them in small width, about 740 pixels. When switching between show/hide with MSIE the "show" table wants to display about 960 pixels. If I set the outer table to ' style="table-layout: fixed;" ' then MSIE chooses to force the width to 960 pixels.
4
6151
by: Alex Meier | last post by:
I have the following problem: I need a simple, tabular layout in a webshop. - left column: navigation column with approx. 170px width - right column: content area the goal: the left column should contain a few "boxes" (these are HTML- tables) which should be all of the same width. So, I attributed the left column with 'width="170"' and assigned the attribute 'width="100%"' to all contained <table>s. This should
5
169726
by: Jean Pion | last post by:
Dear readers, Can anyone explain how to set column width of a table in ccs. I use the following style in an external stylesheet: table.tbl { table-layout:fixed; border-top: 5px solid #333; border-collapse: collapse; background: #fff; width: 95%} table.tbl td { border-bottom: 1px dashed #33ccff; padding: 2px 5px; text-overflow:ellipsis; overflow:hidden; white-space:nowrap; }
2
1450
by: Stewart | last post by:
Originally posted in comp.lang.javascript: Newsgroups: comp.lang.javascript From: "Stewart" Date: 23 Aug 2005 02:50:04 -0700 Local: Tues, Aug 23 2005 10:50 am Subject: FireFox, RemoveChild, AppendChild, making width grow? Hi,
4
1707
by: Ed L. | last post by:
I am trying to identify tables with significant diskspace "leakage" due to in appropriately low max_fsm_pages settings. I can see the results of VACUUM ANALYZE VERBOSE output counts of tuples and unused tuples, and understand that (1 - (tuples/unused)) is the amount of diskspace available to be reclaimed with a VACUUM FULL or dump/reload. Is there a way to identify the numbers of unused tuples without performing a VACUUM? Is it stored...
5
11022
by: Taras_96 | last post by:
Hi everyone, Can anyone tell me why the top paragraph block stretches across the screen (as you would expect), while the bottom div doesn't stretch across the entire screen? When I set the width to 100% (which I interpret as saying 'make this width the same width as the parent (which is the entire screen)) the div is made just wide enough to fit it's contents, and if I decrease the value for the width, the width of the div stretches?!
10
4499
by: Frankie | last post by:
It appears that System.Random would provide an acceptable means through which to generate a unique value used to identify multiple/concurrent asynchronous tasks. The usage of the value under consideration here is that it is supplied to the AsyncOperationManager.CreateOperation(userSuppliedState) method... with userSuppliedState being, more or less, a taskId. In this case, the userSuppliedState {really taskId} is of the object type,...
0
8680
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8609
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9169
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...
0
9030
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8899
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
7738
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...
1
6528
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
1
3052
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
2335
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.