Solved

JS Events

Posted on 2004-08-24
6
290 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Help with Javascript to round decimal points to 2 13 31
alert on input text 2 23
HTML auto refresh to another site 4 28
15 puzzle in Javascript/html 2 36
Avoid defining the variables in the global scope; trying to define them in a local function scope. Because:   • Look-up is performed every time a variable is accessed.   • Variables are resolved backwards from most specific to least specific scope…
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
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…

735 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