Disabling middle click scrolling with javascript

前端 未结 4 2011
礼貌的吻别
礼貌的吻别 2020-11-30 11:21

Background: I am creating a table reminiscent of whenisgood.net, in that it has click-n-drag toggling for table elements. I want to call different types of

4条回答
  •  囚心锁ツ
    2020-11-30 12:26

    This is an old question...but if I'm understanding it properly, you want to disable scrolling via the middle mouse button click.

    Nowadays, you can do this with a single line of vanilla JS:

    document.body.onmousedown = function(e) { if (e.button === 1) return false; }
    

提交回复
热议问题