How to Use JS to detect mouse color on a webpage scroll bar

Source: Internet
Author: User

How to Use JS to detect mouse color on a webpage scroll bar

This article mainly introduces how to use javascript to detect mouse color on a webpage scroll bar. The example analyzes javascript's operation skills for mouse events, which has some reference value. For more information, see

 

 

This article describes how to use JavaScript to detect mouse color changes on a webpage scroll bar. Share it with you for your reference. The specific implementation method is as follows:

 

The Code is as follows:

<Html>
<Head>
<Title> JavaScript enables the mouse to change color when the webpage scroll bar is located </title>
</Head>
<Body>
Let's look at the scroll bar on the right? Pretty? When you place the mouse, the color will change?
<Br> <Script language = "JavaScript">
<! --
Function scrollBar (line, face, theme)
{
If (! Line |! Face)
{
Line = null;
Face = null;
Switch (theme)
{
Case "blue ":
Var line = "#78 AAFF ";
Var face = "# EBF5FF ";
Break;
Case "orange ":
Var line = "# FBBB37 ";
Var face = "# FFF9DF ";
Break;
Case "red ":
Var line = "# FF7979 ";
Var face = "# FFE3DD ";
Break;
Case "green ":
Var line = "#00C600 ";
Var face = "# D1EED0 ";
Break;
Case "neo ":
Var line = "# BC7E41 ";
Var face = "# EFE0D1 ";
Break;
}
}
With (document. body. style)
{
ScrollbarDarkShadowColor = line;
Scrollbar3dLightColor = line;
ScrollbarArrowColor = "black ";
ScrollbarBaseColor = face;
ScrollbarFaceColor = face;
ScrollbarHighlightColor = face;
ScrollbarShadowColor = face;
ScrollbarTrackColor = "# F3F3F3 ";
}
}
Function colorBar (){
Var w = document. body. clientWidth;
Var h = document. body. clientHeight;
Var x = event. clientX;
Var y = event. clientY;
If (x> w) scrollBar ('#000080', '# bfdfff'); // Your colors
Else scrollBar (null, null, "neo"); // A predefined theme
}
If (document. all ){
ScrollBar (null, null, "neo ");
Document. onmousemove = colorBar;
}
// -->
</Script>
<Br/>
<Div style = "width: 100%; height: 1000px;"> </div>
</Body>
</Html>

 

I hope this article will help you design javascript programs.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.