How can I determine the height of a horizontal scrollbar, or the width of a vertical one, in JavaScript?
The way Antiscroll.js
does it in it's code is:
function scrollbarSize () {
var div = $(
''
+ ''
);
$('body').append(div);
var w1 = $(div).innerWidth();
var w2 = $('div', div).innerWidth();
$(div).remove();
return w1 - w2;
};
The code is from here: https://github.com/LearnBoost/antiscroll/blob/master/antiscroll.js#L447