DOM Cell Width in IE

Discussion in 'Javascript' started by VUNETdotUS, Nov 21, 2007.

  1. VUNETdotUS

    VUNETdotUS Guest

    Hello,
    I have a simple structure of table created in DOM:
    table:
    row1:
    cell1 cell2
    row2:
    cell1 (colSpan=2)

    cell2 has a style.width = "0px" because I hide it first. The if I need
    to put something inside of cell2, I modify its style.width = "150px"
    and put some innerHTML in.

    The problem occurs when some DIV content is placed inside cell1 of
    row2 (where colspan=2 is used). DIV content breaks the width of cell2
    and it is not 150 as set but over 50% or something.

    I tried: setting width of DIV to 90%, setting width instead of
    style.width to cell2, a few more things but NOTHING worked. Any ideas?
    It works fine in FF, and in IE when DIV is not appended.

    Thanks
     
    VUNETdotUS, Nov 21, 2007
    #1
    1. Advertising

  2. VUNETdotUS wrote:
    > I have a simple structure of table created in DOM:
    > table:
    > row1:
    > cell1 cell2
    > row2:
    > cell1 (colSpan=2)
    >
    > cell2 has a style.width = "0px" because I hide it first. The if I need
    > to put something inside of cell2, I modify its style.width = "150px"
    > and put some innerHTML in.


    However, you should not. Instead, you should set style.display="none" to
    hide the element and style.display="" to show it, and use a DOM Level 2
    approach to modify both the element's content and the `colspan' attribute of
    the first cell of the second row, respectively.

    > The problem occurs when some DIV content is placed inside cell1 of
    > row2 (where colspan=2 is used). DIV content breaks the width of cell2
    > and it is not 150 as set but over 50% or something.


    See?

    > I tried: setting width of DIV to 90%, setting width instead of
    > style.width to cell2, a few more things but NOTHING worked. Any ideas?
    > It works fine in FF, and in IE when DIV is not appended.


    Understanding HTML and CSS before attempting CSS DOM scripting would be a
    good idea.


    PointedEars
    --
    Prototype.js was written by people who don't know javascript for people
    who don't know javascript. People who don't know javascript are not
    the best source of advice on designing systems that use javascript.
    -- Richard Cornford, cljs, <f806at$ail$1$>
     
    Thomas 'PointedEars' Lahn, Nov 23, 2007
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. AndrewF
    Replies:
    1
    Views:
    845
    Bruce Barker
    Oct 10, 2005
  2. news.rcn.com
    Replies:
    1
    Views:
    9,809
    Chris Smith
    Jul 12, 2004
  3. Phillip Roncoroni
    Replies:
    14
    Views:
    1,140
    Toby A Inkster
    Apr 5, 2004
  4. Replies:
    0
    Views:
    523
  5. Empire City
    Replies:
    3
    Views:
    432
    Empire City
    Apr 30, 2004
Loading...

Share This Page