1

is it possible to capture a click event on a scrollbar? I have some code where i am observing the click and mousedown events on the document. However, it seems that when I click on the scrollbar, the event is not captured. This leads me to believe that the scrollbars aren't really part of the document. (Assumption :-)) Is this a correct assumption? What is the right way to do this so that the behaviour is consistent across all major browsers?

sample code

document.observe('click', function(evt){
    //do something
    //blah blah blah
});

Thanks

1 Answer 1

2

Correct. The closest you can get is the scroll event. It'll work on every element that has a scrollbar, and it will fire on both mouse scroll with scroll bar, scroll wheel, arrow keys, page up/down, etc. Here's a brief jQuery example.

jQuery(document).scroll(function () {
    console.log("foo")
});

That's the best suggestion I can give you - I can't imagine any other uses for a scroll bar click event.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.