Getting the Scrollbar Width
May 9th, 2008
I've been asked a few times if Dimensions would provide a method for getting the scrollbar width. In Dimensions 1.0 I created an internal method for finding the scrollbar width to hack around some browser limitations. I eventually found other ways around those limitations and that code is no longer in Dimensions. I know that in some unusual cases it can be useful, so I want to go ahead and provide that code as one of my jQuery snippets. It is just a single method added to the jQuery namespace called getScrollbarWidth.
-
$.getScrollbarWidth();

May 11th, 2008 at 2:24 am
In IE 7.0 your example shows no scroll and text says that "The scrollbar width is 0" =)
May 11th, 2008 at 11:48 am
Thanks Aleksandr. My original need for the scrollbar width was not in IE. Silly me ... I forgot about that. After trying a few things I had to end up using a textarea to get the scrollbar width in IE. I've updated the snippet and example. :)
May 13th, 2008 at 8:27 am
intelligent way to get the width. nice job.