#1
  1. No Profile Picture
    minaz
    Guest
    Devshed Newbie (0 - 499 posts)
    Hi,

    I have a couple layers that I would like to change the background color for in Javascript. How do I do this?

    I tried this... but it gave me an error.

    document["lyr"].layer-background-color = "red";

    The dashes in the layer-background-color property causes error in Netscape.

    Can someone please help me, Thanks.
  2. #2
  3. No Profile Picture
    SHAWSHANK
    Guest
    Devshed Newbie (0 - 499 posts)
    I have tried to change layer properties too, but to no avail. This is particularly problematic when using tables in layers. However, I think your issue may be that you may be mixing style syntax with JS syntax. try:

    documents[yourlayername].bgcolor = red;

    instead.

  4. #3
  5. No Profile Picture
    click_46
    Guest
    Devshed Newbie (0 - 499 posts)
    both wrong...

    document.layers[layername].bgColor = myColor

    Later,

    click_46
  6. #4
  7. No Profile Picture
    Peter.G
    Guest
    Devshed Newbie (0 - 499 posts)
    As far as I know, when you use style syntax, and have anything with a '-' in it, you got to remove the '-' and capitalize the character after it to get it to work in JS.
    So 'layer-background-color' would be
    'layerBackgroundColor'.

    ------------------
    Peter.G
    peter@gladh.com

Similar Threads

  1. Changing stylesheet classes in Javascript
    By coredumped in forum JavaScript Development
    Replies: 7
    Last Post: January 3rd, 2008, 01:29 AM
  2. Changing the valign attribute of a cell via Javascript
    By Malinali in forum JavaScript Development
    Replies: 1
    Last Post: July 7th, 2003, 10:22 AM
  3. JavaScript not working...
    By FireWire in forum JavaScript Development
    Replies: 2
    Last Post: July 1st, 2003, 12:37 PM
  4. layer background image javascript
    By dirtybbq in forum JavaScript Development
    Replies: 2
    Last Post: June 1st, 2003, 08:30 PM
  5. Changing background image of a layer using Javascript
    By coredumped in forum JavaScript Development
    Replies: 1
    Last Post: September 25th, 2002, 07:25 PM

IMN logo majestic logo threadwatch logo seochat tools logo