开发者

capturing click events on web-browser scrollbars

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 m开发者_JAVA百科ajor browsers?

sample code

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

Thanks


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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜