How can I get the browser's scrollbar sizes?

后端 未结 23 2485
孤街浪徒
孤街浪徒 2020-11-22 06:08

How can I determine the height of a horizontal scrollbar, or the width of a vertical one, in JavaScript?

23条回答
  •  野性不改
    2020-11-22 06:15

    For me, the most useful way was

    (window.innerWidth - document.getElementsByTagName('html')[0].clientWidth)
    

    with vanilla JavaScript.

提交回复
热议问题