Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HTML What is the height of a horizontal scrollbar?

For an overlay i need to know the height of a vertical scrollbar.

What can i do to get this value? And is the height the same in FireFox and Internet Explorer?

Thnx

like image 924
Martijn Avatar asked Jan 23 '23 21:01

Martijn


1 Answers

What can i do to get this value?

function getScrollSizes() { // call after document is finished loading
    var el= document.createElement('div');
    el.style.visibility= 'hidden';
    el.style.overflow= 'scroll';
    document.body.appendChild(el);
    var w= el.offsetWidth-el.clientWidth;
    var h= el.offsetHeight-el.clientHeight;
    document.body.removeChild(el);
    return new Array(w, h);
}

And is the height the same in FireFox and Internet Explorer?

No. The height isn't even the same in Internet Explorer and Internet Explorer. Variables such as dpi settings, theme and OS version can also affect it.

like image 139
bobince Avatar answered Jan 31 '23 18:01

bobince