Given a with a fixed width, I would like its \"active width\" to be constant (in px). By \"active width\" I mean the
I was looking for something similar - here is what i found
function measureScrollbar() {
var $c = $("").appendTo("body");
var dim = {
width: $c.width() - $c[0].clientWidth,
height: $c.height() - $c[0].clientHeight
};
$c.remove();
return dim;
}
Source : Slickgrid uses this - https://github.com/mleibman/SlickGrid/blob/master/slick.grid.js#L378
Or
Use Google Closure Library -link
/**
* Returns the scroll bar width (represents the width of both horizontal
* and vertical scroll).
*
* @param {string=} opt_className An optional class name (or names) to apply
* to the invisible div created to measure the scrollbar. This is necessary
* if some scrollbars are styled differently than others.
* @return {number} The scroll bar width in px.
*/
goog.style.getScrollbarWidth = function(opt_className) {
// Add two hidden divs. The child div is larger than the parent and
// forces scrollbars to appear on it.
// Using overflow:scroll does not work consistently with scrollbars that
// are styled with ::-webkit-scrollbar.
var outerDiv = goog.dom.createElement('div');
if (opt_className) {
outerDiv.className = opt_className;
}
outerDiv.style.cssText = 'overflow:auto;' +
'position:absolute;top:0;width:100px;height:100px';
var innerDiv = goog.dom.createElement('div');
goog.style.setSize(innerDiv, '200px', '200px');
outerDiv.appendChild(innerDiv);
goog.dom.appendChild(goog.dom.getDocument().body, outerDiv);
var width = outerDiv.offsetWidth - outerDiv.clientWidth;
goog.dom.removeNode(outerDiv);
return width;
};