Monday, June 22, 2009

Scroll bars not working and MSThemeCompatible

I recently had a problem where scroll bars were not working properly when windows XP was themed in the default theme (not classic). The scroll bar would not move if one used the arrows, or clicked in the area between the bar and the arrows. It could still be used by dragging it up and down.

The weirdest part of this issue was that the scroll bar worked normally in the windows 'classic' theme, but would seize to function correctly if you switched themes over to the ugly blue default theme.

I should also add that this scrollbar was part of a javascript widget where its position determined position of another DIV in the widget.

Solution (Hack):
Before i found the proper solution i came with a hack - on page load, add 1px to the width of the scrollbar and change its css left to -1px like so (this is jQuery):

$scrollY.css({"position":"relative", "left":"-1px"});
$scrollY.width($scrollY.width() + 1);

This seemed to work for some reason, the scrollbar works after this is applied.

Solution:
I later stumbled on another solution that didnt smell like such a hack, but i am not sure what side effects it has other then making the scrollbar work. The solution is to set an a meta tag in IE only (because firefox has a bug with this metatag):

No comments:

Post a Comment