Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Should a click handler be run when clicking on a scrollbar

Take a look at these HTML fragments: Jsfiddle

<style>
  div { 
    margin:20px; 
    border: 30px red solid; 
    padding: 20px; 
    background-color:green;
    overflow-y:scroll; 
  }
</style>

<div onclick="alert('div clicked');">click me</div>

Now, if the user clicks on the scrollbar in Firefox or Chrome, the click handler on the div element won't fire. On the other hand, in IE the click handler does fire.

Which behaviour is correct? Is the expected behaviour defined anywhere?

like image 229
Alohci Avatar asked Aug 17 '14 12:08

Alohci


People also ask

How do I click the scroll bar?

Scroll bars are utilized using the mouse, touchpad, or keyboard. With a mouse, you can move the scroll bar by clicking the scroll arrow at either end of the scroll bars. You may also click an empty portion of the scroll bar, or click-and-drag the scroll box.

Which event does a scrollbar component cause?

The scroll event fires when you scroll a webpage or an element. For a page, the scrollX and scrollY properties return the number of pixels that the document is currently scrolled horizontally and vertically.

What does window onscroll do?

The onscroll event occurs when an element's scrollbar is being scrolled. Tip: use the CSS overflow style property to create a scrollbar for an element.

How do I show scrollbar only when needed?

Use overflow: auto . Scrollbars will only appear when needed. (Sidenote, you can also specify for only the x, or y scrollbar: overflow-x: auto and overflow-y: auto ).


1 Answers

w3 recommendations suggest that the scrollbar should be placed between the inner border edge and the outer border padding edge of an element. Also the scrollbar's dimensions should be subtracted from your element's dimensions.

Long story short, the scrollbar should not be inside the element. and the element's height/width should be adjusted appropriately.

like image 91
Ajk_P Avatar answered Oct 19 '22 17:10

Ajk_P