I would like to know how to disable the scroll central button ?
I do not want to take the scroll just the scroll button of the mouse that has a right-hand side up and down when I click it, I want disable it.
I would like to know how to disable the scroll central button ?
I do not want to take the scroll just the scroll button of the mouse that has a right-hand side up and down when I click it, I want disable it.
You can try something like this:
$('body').mousedown(function(e) {
if (e.button == 1) return false;
});
Note that older browsers may not work this way. Try this code on JSFiddle .
You can prevent the scroll button from clicking, for example:
$('body').mousedown(function(e){
/*button == 0 botão esquerdo do mouse
*button == 1 botão do meio, ou botão de scroll
*button == 2 botão direito do mouse
*/
if(e.button==1){
alert('Botão desabilitado');
return false
}
});
div{
width:100%;
height:300px;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script><div>Cliquecomobotãodoscroll</div>
Withpurejavascript,do:
document.body.onmousedown = function(e){
if(e.button == 1) {
alert('Botão desabilitado');
return false;
}
}
div{
width:100%;
height:600px;
}
<div>Clique com o botão de scroll</div>