JavaScript scrollbar width detection?
November 4, 2004 10:36 AM   Subscribe

JavaScript: is it possible to detect a Windows XP user's chrome settings? For some perverse reason, chromed-out Windows XP scrollbars are a pixel wider than their "Classic" counterparts and it's breaking an interface.
posted by yerfatma to Computers & Internet (6 answers total)
 
Users are able to specify the width of their scrollbars, XP or not. An interface that is thrown off by that is one that could use a rethink.
posted by sageleaf at 11:06 AM on November 4, 2004


Don't all browsers define screen sizes by their internal dimensions? Why does the scroller size effect it?

I know that doesn't answer your question (and I suspect the answer is 'no') but it's puzzling me...
posted by twine42 at 11:30 AM on November 4, 2004


Response by poster: An interface that is thrown off by that is one that could use a rethink.

The problem isn't the interface: it's the fact the browser neglects to account for the difference in scrollbar size. While bar sizes may vary from browser to browser, most browsers know how wide their scrollbars are and adjust accordingly. XP with the chrome turned on has a 19 or 20px wide scrollbar but still acts like the thing is 18px wide (or whatever the numbers are . . . you get the idea).

Why does the scroller size effect it?

It's an interface for a web-based tool. The whole thing runs at 100% of screen height and if the content area is larger than that it scrolls (instead of the browser). So the problem child scrollbar is actually inside the browser window.
posted by yerfatma at 12:19 PM on November 4, 2004


If you're forcing the browser full-screen, I would expect this to be a purely in-house controlled system where you'd be able to enforce a particular style. If you're trying to force full-screen on innocent surfers, you've got more problems than the width of the scroll bar.
posted by krisjohn at 3:36 PM on November 4, 2004


Best answer: > is it possible to detect a Windows XP user's chrome settings?

Not directly, AFAIK.

But as sageleaf mentions, scroolbars can be configured to be any size in most OSes.

> For some perverse reason, chromed-out Windows XP scrollbars are a pixel wider

Take advantage of this. Make a contentless, borderless div with 'overflow: scroll' and use JavaScript to measure the difference between its clientWidth and offsetWidth; that'll be the width in pixels of the scrollbar, whatever the theme/user settings.

See http://msdn.microsoft.com/workshop/author/om/measuring.asp for more. These JS properties are non-standard, but do also work on at least newer Mozilla-based browsers.
posted by BobInce at 1:53 AM on November 5, 2004 [1 favorite]


Response by poster: Make a contentless, borderless div with 'overflow: scroll' and use JavaScript to measure the difference between its clientWidth and offsetWidth;

Now we're talking. The scrollbars in question are on a div with overflow:scroll. If I can get IE to report that difference, I'm golden. Thanks.

I tried to post this last night but AskMe wasn't having it: I've clearly done an awful job of describing what/ why I need what I'm looking for. This isn't some PoS amateur hour thing where I'm blowing IE up into kiosk mode and screwing with users' browsers. Promise. The thing has been blessed by ID, UI, Design, etc. It's just bugging the hell out of me (and the designer to a lesser extent) that the DIV's scrollbar is one pixel off in XP's chrome mode.
posted by yerfatma at 4:52 AM on November 5, 2004


« Older Why is faith a virtue?   |   Libertarian Governments around the World Newer »
This thread is closed to new comments.