最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - HTML What is the height of a horizontal scrollbar? - Stack Overflow

programmeradmin0浏览0评论

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

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

Share Improve this question edited Mar 11, 2015 at 8:33 S Gupta 1,5872 gold badges14 silver badges20 bronze badges asked Jan 19, 2009 at 11:06 MartijnMartijn 24.8k61 gold badges179 silver badges268 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 10

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.

发布评论

评论列表(0)

  1. 暂无评论