Home > Web Front-end > JS Tutorial > Guess the reason why JS cannot capture the mouse up event on the scroll bar_javascript skills

Guess the reason why JS cannot capture the mouse up event on the scroll bar_javascript skills

WBOY
Release: 2016-05-16 17:55:01
Original
1074 people have browsed it

For example, in a web chat room, the scroll bar will automatically scroll down as the content increases.
When the user presses the mouse on the scroll bar, we can assume that he (she) is browsing the chat content, so a good user experience at this time will not allow the scroll bar to scroll automatically.
In order to implement this function, the first thing you may think of is the mouse down and mouse up events.
However, during the specific implementation, we will find that when the left mouse button is pressed and released on the scroll bar, the mouse up cannot be captured. For example,

Copy the code The code is as follows:


< head>


< /head>


< div style="height:500px; width:500px">





Save it as an html format file, open it in the browser, then left-click on the scroll bar to try, and then click elsewhere to try.
Since I haven’t studied the W3C documents in depth, I can only guess here.
Considering the characteristics of the scroll bar, the browser may setCapture the scroll bar when the mouse is pressed, and releaseCapture it after the mouse is released. The scroll bar does not belong to the Dom object, so it cannot be released before the mouse is released. Capture the mouseup event.
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template