This article describes the method of JS to realize the mouse color change by scroll bars on web pages. Share it for your reference. The specific implementation method is as follows:
Copy the code as follows: <html>
<head>
<title>JS realizes web scroll bar sensing mouse color change</title>
</head>
<body>
Turn your eyes to the scroll bar on the right and look at it? Isn't it very beautiful? Will the mouse change the color?
<br><br><hr> Collected on the Internet, only for exchange of interests and learning, and not for commercial purposes. </p>
<script language="JavaScript">
<!--
function scrollBar(line,face,theme)
{
if (!line||!face)
{
line=null;
face=null;
switch(theme)
{
case "blue":
var line="#78AAFF";
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></div>
</body>
</html>
I hope this article will be helpful to everyone's JavaScript programming.