MS DOM and style and class

Discussion in 'Javascript' started by Aaron Gray, Dec 15, 2006.

  1. Aaron Gray

    Aaron Gray Guest

    Hi,

    I have written some DOM code to create a table but .setAttribute( "style",
    ....) and .setAttribute( "class", ...) are not working on IE where they _do_
    work on both FF and Opera.

    I am using 4.01 transitional.

    Could someone give me the lowdown on this and give me an explanation please
    :)

    I can post a link to a whittled down example if really required.

    Aaron
     
    Aaron Gray, Dec 15, 2006
    #1
    1. Advertising

  2. Aaron Gray

    Randy Webb Guest

    Aaron Gray said the following on 12/14/2006 10:59 PM:
    > Hi,
    >
    > I have written some DOM code to create a table but .setAttribute( "style",
    > ...) and .setAttribute( "class", ...) are not working on IE where they _do_
    > work on both FF and Opera.
    >
    > I am using 4.01 transitional.
    >
    > Could someone give me the lowdown on this and give me an explanation please
    > :)


    tableRef.style.property
    tableRef.className

    IE doesn't like setAttribute

    --
    Randy
    Chance Favors The Prepared Mind
    comp.lang.javascript FAQ - http://jibbering.com/faq
    Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
     
    Randy Webb, Dec 15, 2006
    #2
    1. Advertising

  3. Aaron Gray

    Aaron Gray Guest

    No I am refering to DOM. e.g.

    var tr = document.createElement("tr");
    var td = document.createElement("td");
    tr.appendChild(td);

    tr.setAttribute( "style", "font-size:xx-small");
    thead.appendChild(tr);

    The setAttribute only works on FF and Opera not IE.

    Aaron

    "Randy Webb" <> wrote in message
    news:...
    > Aaron Gray said the following on 12/14/2006 10:59 PM:
    >> Hi,
    >>
    >> I have written some DOM code to create a table but .setAttribute(
    >> "style", ...) and .setAttribute( "class", ...) are not working on IE
    >> where they _do_ work on both FF and Opera.
    >>
    >> I am using 4.01 transitional.
    >>
    >> Could someone give me the lowdown on this and give me an explanation
    >> please :)

    >
    > tableRef.style.property
    > tableRef.className
    >
    > IE doesn't like setAttribute
    >
    > --
    > Randy
    > Chance Favors The Prepared Mind
    > comp.lang.javascript FAQ - http://jibbering.com/faq
    > Javascript Best Practices -
    > http://www.JavascriptToolbox.com/bestpractices/
     
    Aaron Gray, Dec 15, 2006
    #3
  4. Aaron Gray

    VK Guest

    Aaron Gray wrote:
    > No I am refering to DOM. e.g.
    >
    > var tr = document.createElement("tr");
    > var td = document.createElement("td");
    > tr.appendChild(td);
    >
    > tr.setAttribute( "style", "font-size:xx-small");
    > thead.appendChild(tr);


    See my answer at
    <http://groups.google.com/group/comp.lang.javascript/msg/f9a11b90f45d2a3a>

    Stop patchning attribute nodes in the document tree instead of
    scripting DOM (which is what you want as I can tell).

    tr.style.fontSize = 'xx-small';
     
    VK, Dec 15, 2006
    #4
  5. Aaron Gray

    Aaron Gray Guest

    > tr.style.fontSize = 'xx-small';

    Nice, thanks alot, thats sorted that onr out at last.

    Aaron
     
    Aaron Gray, Dec 16, 2006
    #5
    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. Thorsten Meininger
    Replies:
    0
    Views:
    448
    Thorsten Meininger
    Jul 28, 2004
  2. dlo_olb
    Replies:
    2
    Views:
    2,334
    Fredrik Lundh
    Jun 25, 2003
  3. Ken Varn
    Replies:
    0
    Views:
    492
    Ken Varn
    Apr 26, 2004
  4. Amir Hardon
    Replies:
    0
    Views:
    270
    Amir Hardon
    May 31, 2004
  5. Jayden
    Replies:
    9
    Views:
    301
    alex23
    Sep 27, 2012
Loading...

Share This Page