Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function getScrollbarWidth() {
- var outer, inner, widthScollbar, widthNoScrollbar;
- outer = $('<div>', {
- id: '__outer',
- css: {
- 'visibility': 'hidden',
- 'width': '100px'
- }
- }).appendTo('body');
- widthScollbar = outer.outerWidth();
- // force scrollbars
- outer.css('overflow', 'scroll');
- inner = $('<div>', {
- id: '__outer',
- style: {
- 'width': '100%'
- }
- }).appendTo('#__outer');
- // add innerdiv
- widthNoScrollbar = inner.outerWidth();
- console.log(widthScollbar, widthNoScrollbar);
- // remove divs
- outer.remove();
- return widthNoScrollbar - widthScollbar;
- }
- $('body').text('ScrollbarWidth: ' + getScrollbarWidth() );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement