SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    Pragmatic Programmer halfasleeps's Avatar
    Join Date
    Feb 2006
    Location
    Altoona, PA. USA
    Posts
    1,945
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    changing a scrollbar color?

    i am trying to change the color of the scrollbar

    im uding this code:

    Code:
    function colorBar(colorA,colorB){
    with(document.body.style)
    		{
    			scrollbarBaseColor=colorB;
    			scrollbarDarkShadowColor=colorA;
    			scrollbar3dLightColor=colorA;
    			scrollbarTrackColor=colorA;
    			scrollbarArrowColor=colorA;			
    			scrollbarFaceColor=colorB;
    			scrollbarHighlightColor=colorB;
    			scrollbarShadowColor=colorB;			
    		}
    }
    colorBar('006699','00FFFF');
    that changes scrollbars for things like <textarea> but the main body scroll bar is uneffected? anyone know what i need to do?

    thanks
    Altoona Design
    Freelance Flex developer for hire.
    ActionScript Programmer with 8 Years Experience.

  2. #2
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    17,290
    Mentioned
    198 Post(s)
    Tagged
    3 Thread(s)

    scrollbar styling

    This is old, but last I knew it worked.
    HTML Code:
    <STYLE>BODY {
    	SCROLLBAR-FACE-COLOR: #000000; SCROLLBAR-HIGHLIGHT-COLOR: black; SCROLLBAR-SHADOW-COLOR: red; SCROLLBAR-3DLIGHT-COLOR: red; SCROLLBAR-ARROW-COLOR: red; SCROLLBAR-DARKSHADOW-COLOR: black
    }
    </STYLE>
    Of course the javascript styles would be in the syntax you used in the snippet (except for maybe scrollbarDarkshadowColor=colorA; and scrollbar3dlightColor=colorA I've never before seen ~ with(document.body.style) ~ Will the script work if you change the lines to:
    Code:
    document.body.scrollbarBaseColor.style=colorB;
    ??

  3. #3
    Pragmatic Programmer halfasleeps's Avatar
    Join Date
    Feb 2006
    Location
    Altoona, PA. USA
    Posts
    1,945
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Mittineague
    This is old, but last I knew it worked.
    HTML Code:
    <STYLE>BODY {
    	SCROLLBAR-FACE-COLOR: #000000; SCROLLBAR-HIGHLIGHT-COLOR: black; SCROLLBAR-SHADOW-COLOR: red; SCROLLBAR-3DLIGHT-COLOR: red; SCROLLBAR-ARROW-COLOR: red; SCROLLBAR-DARKSHADOW-COLOR: black
    }
    </STYLE>
    Of course the javascript styles would be in the syntax you used in the snippet (except for maybe scrollbarDarkshadowColor=colorA; and scrollbar3dlightColor=colorA I've never before seen ~ with(document.body.style) ~ Will the script work if you change the lines to:
    Code:
    document.body.scrollbarBaseColor.style=colorB;
    ??
    i tried changing to what you suggested and then no scrollbars were colored, with the code i used the scrollbars inside the body were colored but the main ones for the browser were not effected

    this is also the first time ive used with() with javascript but ive used it many times with actionscript, its like short hand.

    with(this.that){
    what1 = a;
    what2 = b;
    }

    is equivlant to
    this.that.what1 = a;
    this.that.what2 = b;
    Altoona Design
    Freelance Flex developer for hire.
    ActionScript Programmer with 8 Years Experience.

  4. #4
    SitePoint Wizard Pepejeria's Avatar
    Join Date
    Jan 2005
    Location
    Too far up north
    Posts
    1,566
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Just a tip, dont use with(), its slow and dumb

  5. #5
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    17,290
    Mentioned
    198 Post(s)
    Tagged
    3 Thread(s)

    syntax

    I just checked at the msdn site. The scripting synatx is:
    object.style.scrollbarBaseColor = color
    So it seems that document.body.style.scrollbarBaseColor = #f00; should work.
    Maybe without the with?

  6. #6
    SitePoint Wizard Pepejeria's Avatar
    Join Date
    Jan 2005
    Location
    Too far up north
    Posts
    1,566
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Actually, this explanation is even better than the ones above telling how much with() sucks


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
  •