codetoad.com
  ASP Shopping CartForum & BBS
  - all for $20 from CodeToad Plus!
  
  Home || ASP | ASP.Net | C++/C# | DHTML | HTML | Java | Javascript | Perl | VB | XML || CodeToad Plus! || Forums || RAM 
Search Site:



Home » DHTML » Article

Manipulate Scrollbar Colors Using CSS and JavaScript

Article by: Mike Thompson (1/6/2003)
Bookmark us now! Add to Favourites
Email a friend!Tell a friend
Summary: The thing about the default color of scrollbars is that it's dull and ugly -- usually this color is gray. Wouldn't it be nice to change this color to better fit the overall theme of your site? Luckily, Cascading Style Sheets and JavaScript can be used to do just that!
Viewed: 78487 times Rating (238 votes): 
 1.8 out of 5
 Rate this Article  Read Comments  Post Comments

Manipulate Scrollbar Colors Using CSS and JavaScript



The thing about the default color of scrollbars is that it's dull and ugly -- usually this color is gray. Wouldn't it be nice to change this color to better fit the overall theme of your site? Luckily, Cascading Style Sheets and JavaScript can be used to do just that!

Using CSS

In CSS, simply add the below definitions to the top of your page to customize the browser's scrollbar colors. The great thing about CSS is that browsers that don't understand it will just skip it. Scrollbar painting is supported by IE5.5 and up.

Select All Code


Bet you never realized the scrollbar consisted of that many components! The first three definitions are the most important, as they correspond to the most visible aspects of the scrollbar. Feel free to play around with the other definitions to see what they affect.

Using JavaScript

You can also use JavaScript to dynamically change the scrollbar color. This is useful when you wish to do something fancy, like alternating the scrollbar from one color to another. The JavaScript translation of the scrollbar CSS definitions are:

Select All Code


Here's an example of a "blinking" scrollbar, which changes color every second:

Select All Code


A more elaborate example of scrollbar manipulation using JavaScript, called onMouseover Scrollbar Effect, is written by Svetlin Staev. This changes the scrollbar colors when you move your mouse over and away from it.

I'm seeing more and more sites customize the scrollbar color to blend in with the rest of their sites. I hope you find these tips useful in helping you do the same!




CodeToad Experts

Can't find the answer?
Our Site experts are answering questions for free in the CodeToad forums
Rate this article:     Poor Excellent
View highlighted Comments
User Comments on 'Manipulate Scrollbar Colors Using CSS and JavaScript'
RELATED ARTICLES
Simple Thumbnail Browsing Solution
by Troy Wolf
This simple script allows the user to select from several thumbnail images and view the larger image, using a mixture of DHTML and Cascading style sheets.
Creating CSS Buttons
by Thomas D. Greer
With Cascading Style Sheets, you can turn ordinary hyperlinks into fully functional "buttons", without using JavaScript.
DHTML Javascript Ticker
by Premshree Pillai
This is a JavaScript Ticker which ticks a number of messages like the one shown above. It also has a useful 'Show All' feature.
DHTML Horizontal Scroller
by Premshree Pillai
Scroll text horizontally when the user hovers over a link.
Manipulate Scrollbar Colors Using CSS and JavaScript
by Mike Thompson
The thing about the default color of scrollbars is that it's dull and ugly -- usually this color is gray. Wouldn't it be nice to change this color to better fit the overall theme of your site? Luckily, Cascading Style Sheets and JavaScript can be used to do just that!
DHTML News Bar
by Premshree Pillai
This is the News Bar script which displays a number of messages and rotates them using DHTML.
DHTML Scrolling Image
by Premshree Pillai
Using this script the user can scroll an image left or right by clicking a buttong
DHTML Image Zoom Out
by Premshree Pillai
Click on the image and it zooms out and disappears. This script could be a way to handle advertising or other images.
DHTML Zoom In and Out Script
by Premshree Pillai
Using zoOom, you can zoom in and zoom out any image that is specified in the code.
Simple Mouse Trail using VB Script
by Jeff Anderson
With IE gaining in prominence every day, it's becoming acceptable to use VBScript in web pages. That makes some activities like the mouse trail a real cinch.








Recent Forum Threads
• SoftIce Driver Suite 3.0.1
• metrowerks codewarrior 9.0
• Mapinfo.Professional.v7.0
• GardenGraphics DynaSCAPE Professional 3.02
• Embroidery Great Notions 2004 part01-74
• EFI_BEST_COLORPROOF_V5.0
• AViD.SOFTiMAGE.XSi.V4.2.CD1-NNiSO
• AUTOFX.PHOTOGRAPHIC.EDGES.6.0.CD1
• 0 STI.SASSPro.v2.0.0.2 working full


Recent Articles
ASP GetTempName
Decode and Encode UTF-8
ASP GetFile
ASP FolderExists
ASP FileExists
ASP OpenTextFile
ASP FilesystemObject
ASP CreateFolder
ASP CreateTextFile
Javascript Get Selected Text


© Copyright codetoad.com 2001-2014