Skip to content

Instantly share code, notes, and snippets.

@Jekins
Created January 13, 2016 15:29
Show Gist options
  • Save Jekins/cc5691508ff9a1c3be4b to your computer and use it in GitHub Desktop.
Save Jekins/cc5691508ff9a1c3be4b to your computer and use it in GitHub Desktop.
Возвращает ширину скролла браузера
function scrollbarWidth() {
var
block = $('<div>').css({'height': '50px', 'width': '50px'}),
indicator = $('<div>').css({'height': '200px'});
$('body').append(block.append(indicator));
var
w1 = $('div', block).innerWidth();
block.css('overflow-y', 'scroll');
var
w2 = $('div', block).innerWidth();
$(block).remove();
return (w1 - w2);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment