SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Enthusiast
    Join Date
    Nov 2004
    Location
    NJ
    Posts
    98
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    change bordercolor with javascript

    ok, i know its possible to do something like change the background color using the following code:

    document.getElementById(whatever).backgroundColor='ffff00';

    but i need to do something like the following:

    document.getElementById(whatever).borderColor='ffff00';

    i'm tired of css, and am going on a rampage to get rid of most if not all of it from my site and replace it with javascript so my site can be viewed by other browswer's than just ie

    so if someone can help me figure out how to change border color without using css and purely javascript or html, it would be greatly appreciated

    thanx

  2. #2
    SitePoint Wizard
    Join Date
    Mar 2001
    Posts
    3,537
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    but i need to do something like the following:
    document.getElementById(whatever).borderColor='ffff00';
    i'm tired of css, and am going on a rampage to get rid of most if not all of it from my site and replace it with javascript so my site can be viewed by other browswer's than just ie
    borderColor is a css property and using javascript to move it inline into the html is no different than having it in a css style sheet in the <head> tag except that it won't adhere to the principal of separation of content and style, which means it will be harder to change.

    You would use:

    document.getElementById(whatever).style.borderColor='ffff00';

    If you are having cross browser css problems, instead I suggest you visit the css forum here where they dispense expert advice on the subject. There are crossbrowser problems with javascript as well. For instance, try creating a <div> with a red border and then create a button that changes the color to blue when you click on it, and back to red when you click on it again. When you get it working in IE, try it in Mozilla.
    Last edited by 7stud; Nov 30, 2004 at 01:31.

  3. #3
    SitePoint Enthusiast
    Join Date
    Nov 2004
    Location
    NJ
    Posts
    98
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    thanx

    i used the div element, it worked, thanx
    greatly appreciated, and just in case you wanna see what i did:

    Code:
    <div class=link01 id=name01 onMouseover="Mousehandler(1, 1, 'name01')" onMouseout="Mousehandler(1, 2, 'name01')"><a href="01_metallic_chevron_a.html" class=productsnav>Description</a></div>


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •