August 29, 2000 - Coloring Scrollbars | WebReference

August 29, 2000 - Coloring Scrollbars

Yehuda Shiran August 29, 2000
Coloring Scrollbars
Tips: August 2000

Yehuda Shiran, Ph.D.
Doc JavaScript

Starting from IE 5.5, you can set and modify the color of scrollbars, on the fly. You set the color as follows:

object.style.scrollbarBaseColor = vColor;

where vColor is a color name or an RGB value. This color change affects all elements of the scrollbar: the scroll box, the scroll track, and the scroll arrow buttons.

The following TEXTAREA demonstrates the scrollbarBaseColor property (works only in IE 5.5 and up). Click one of the two links to the right of the window, and color the scrollbar either red or green:

red scrollbars green scrollbars

Here is how we defined the above TEXTAREA and links:

<TEXTAREA ID="longWord" ROWS="10">
Long Line Long Line Long Line Long Line Long Line Long Line Long Line Long Line Long Line Long 
Line Long Line Long Line Long Line Long Line Long Line Long Line Long Line Long Line Long Line
Long Line Long Line Long Line Long Line Long Line Long Line Long Line Long Line Long Line Long
Line Long Line Long Line Long Line Long Line Long Line Long Line Long Line Long Line Long Line
Long Line 
</TEXTAREA>
<A HREF="javascript:void(longWord.style.scrollbarBaseColor='red')"><FONT COLOR="red">red scrollbars</FONT></A>
<A HREF="javascript:void(longWord.style.scrollbarBaseColor='green')"><FONT COLOR="green">green scrollbars</FONT></A>

Notice the usage of void() above. It is necessary to avoid overwriting of the page with the return value from the javascript: call, which is the property assignment value (red or green).