Home     |     .Net Programming    |     cSharp Home    |     Sql Server Home    |     Javascript / Client Side Development     |     Ajax Programming

Ruby on Rails Development     |     Perl Programming     |     C Programming Language     |     C++ Programming     |     IT Jobs

Python Programming Language     |     Laptop Suggestions?    |     TCL Scripting     |     Fortran Programming     |     Scheme Programming Language


 
 
Cervo Technologies
The Right Source to Outsource

MS Dynamics CRM 3.0

Javascript / Client Side Development

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
("thisTableWidth")
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.getElementsByTagName("table");

// Iterate through each table
for (var i = 0; i < eachObject.length; i++)
    {
    // Does this table have a class called ClassA?
    if (eachObject[i].className.indexOf('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.public.scripting.jscript]

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.

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/archive/2006/06/22/13623.aspx

-yanick

On 9 mai, 11:07, Griff <griffithsj_@hotmail.com> wrote:

Add to del.icio.us | Digg this | Stumble it | Powered by Megasolutions Inc