Solved

JS Events

Posted on 2004-08-24
6
287 Views
Last Modified: 2010-05-18
Hello all!

I know there are alot of events in Javascript, such as onClick, onMouseOver, onMouseOut, etc etc etc.

Is there one that control when you release your mouse from an onClick?  like onRelease or something?

basically, I have a scrollbar styled with css (yes, i know this only works in IE), and I want the scrollbar color to change onClick and onRelease (or whatever the event really is).

Any thoughts?  Thanks in advance.
0
Comment
Question by:flow79
  • 3
  • 3
6 Comments
 
LVL 19

Expert Comment

by:dakyd
ID: 11882078
I think the one you're looking for is onMouseUp (there's also it's opposite, on MouseDown)
0
 
LVL 13

Author Comment

by:flow79
ID: 11882091
very cool - let me check it out, and get back to you in a few minutes.
0
 
LVL 13

Author Comment

by:flow79
ID: 11882142
that seems to work (kinda).  do you mind looking at this page for me?  currently, the onMouseDown and onMouseUp work, but only when in the div (not over the scrollbar).  It seems that onMouseDown DOES work on the scrollbar, but onMouseUp doesnt.  Any ideas?

Thanks


<html>
<head>
<title>Untitled</title>
<style type="text/css">
<!--
.scrolly {
      width: 300px;
      height: 100px;
      overflow: auto;
      scrollbar-base-color: #003366;
      scrollbar-arrow-color: #ffffff;
      border: #003366 1px solid;
      padding: 3px;
      font-size: 8pt;
      font-family: verdana;
      color: #003366;
      }
-->
</style>
<script language="JavaScript" type="text/javascript">
<!--
function scrolly(element){
document.all(element).style.scrollbarBaseColor = "#3399cc"
}
function unscrolly(element){
document.all(element).style.scrollbarBaseColor = "#003366"
}
//-->
</script>
</head>
<body>
<div class="scrolly" id="scroller" onMouseDown="scrolly('scroller')" onMouseUp="unscrolly('scroller');">
      <p>
             Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Sed et pede.
             Suspendisse quis risus et elit congue adipiscing. Aliquam erat volutpat.
             Mauris consequat. Maecenas ligula orci, luctus vitae, euismod vel,
             malesuada a, orci. Nullam vel mi vitae tortor nonummy porttitor.
             Maecenas sit amet sem vitae lacus sodales vulputate. Etiam et tellus.
             Nam et felis. Maecenas rhoncus molestie nisl. Phasellus placerat luctus
             ipsum.
      </p>
</div>
</body>
</html>
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 19

Accepted Solution

by:
dakyd earned 500 total points
ID: 11882860
Give this a shot - I left in the document.all since you're okay with IE-only.  Instead of onmouseup/onmousedown, I used onscroll and a timeout to change it back when you're done scrolling.  Hope that helps.

<html>
<head>
<title>Untitled</title>
<style type="text/css">
<!--
.scrolly {
     width: 300px;
     height: 100px;
     overflow: auto;
     scrollbar-base-color: #003366;
     scrollbar-arrow-color: #ffffff;
     border: #003366 1px solid;
     padding: 3px;
     font-size: 8pt;
     font-family: verdana;
     color: #003366;
     }
-->
</style>
<script language="JavaScript" type="text/javascript">
<!--
var timer;
function scrolly(element){
  clearTimeout(timer);
  document.all(element).style.scrollbarBaseColor = "#3399cc";
  timer = setTimeout("unscrolly('scroller')", 250);
}
function unscrolly(element){
  document.all(element).style.scrollbarBaseColor = "#003366"
}
//-->
</script>
</head>
<body>
<div class="scrolly" id="scroller" onscroll="scrolly(this.id)">
           Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Sed et pede.
           Suspendisse quis risus et elit congue adipiscing. Aliquam erat volutpat.
           Mauris consequat. Maecenas ligula orci, luctus vitae, euismod vel,
           malesuada a, orci. Nullam vel mi vitae tortor nonummy porttitor.
           Maecenas sit amet sem vitae lacus sodales vulputate. Etiam et tellus.
           Nam et felis. Maecenas rhoncus molestie nisl. Phasellus placerat luctus
           ipsum.
</div>
</body>
</html>
0
 
LVL 13

Author Comment

by:flow79
ID: 11883318
thats a pretty cool solution - i like it.  Thanks!
0
 
LVL 19

Expert Comment

by:dakyd
ID: 11883384
Well, so long as you like it.  =p  Glad you got what you wanted.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

In this article, we'll look how to sort an Array in JavaScript, including the more advanced techniques of sorting a collection of records either ascending or descending on two or more fields. Basic Sorting of Arrays First, let's look at the …
Having worked on larger scale sites, we found out that you are bound to look at more scalable solutions to integrating widgets, code snippets or complete applications and mesh them into functional sites, in any given composition. To share some of…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

912 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now