3

See usually I'd just use:

$.browser.webkit 

Since we all know webkit is the only one which lets you style the scrollbar. However that's been removed in 1.9 in favour of:

$.support

Which is all fine and dandy except I'm pretty sure you can't check for scrollbar styling support this way. If you can, please let me know, or I'm just going to downgrade back to 1.8 again. The only reason I want to do this is because I'd rather use a built in system a browser has available rather than a javascript solution to style the scrollbar.

Nathan
  • 41
  • 3
  • 5
    This modernizer plugin can do it: https://gist.github.com/948808 or you can pull the code from it to implement it without modernizer. – Kevin B Jan 29 '13 at 20:48
  • @Neal `Webkit !== Chrome` http://en.wikipedia.org/wiki/List_of_web_browsers#WebKit-based – Juan Mendes Jan 29 '13 at 20:49
  • `if (window.chrome) { ... }` – adeneo Jan 29 '13 at 20:49
  • @KevinB Make that an answer, looks correct – Juan Mendes Jan 29 '13 at 20:50
  • @JuanMendes quick google search for detect if browser is webkit got me this: http://jsperf.com/test-if-browser-is-webkit/3 so easy even the OP could have done it.... – Naftali aka Neal Jan 29 '13 at 20:51
  • @Neal, the OP's statement "Since we all know webkit is the only one which lets you style the scrollbar." is wrong, IE and Opera let you do it too, in a different way http://stackoverflow.com/questions/7725652/css-scrollbar-style-cross-browser – Juan Mendes Jan 29 '13 at 20:52
  • @JuanMendes I am going based off the content of the post... – Naftali aka Neal Jan 29 '13 at 20:52
  • @Neal The question is "How would one detect if scrollbar styling is supported...". You would not do that by detecting that the browser is webkit, don't take the OP's statements for granted. Also "so easy even the OP could have done it", that sounds like a Geico caveman commercial, no need to bash the OP, it's still a good thing to add a question like this to SO so others can use it in the future – Juan Mendes Jan 29 '13 at 20:54
  • Oh sorry yes IE and Opera do, I completely forgot lol, I guess I should have left that statement out but KevinB's answer looks good, if he makes it an answer I'll accept :D – Nathan Jan 29 '13 at 20:58
  • This question should not be closed, it's not about how to detect chrome or webkit, it's about how to detect that you can style scrollbars with CSS. @Neal you still voted to close it even after I made it clear what the OP was really asking? – Juan Mendes Jan 30 '13 at 20:08
  • @JuanMendes I **cannot** undo a close vote. Noone can. Once the vote is cast it cannot be undone. – Naftali aka Neal Jan 30 '13 at 20:10

1 Answers1

4

Since KevinVB didn't make an answer out of his comment...

There is no way do detect what that scroll-bar styling is supported with any jQuery built in method. Also, you shouldn't just be looking for webkit browsers, IE and Opera also support it in a different way.

Modernizr is the most complete feature detection tool out there, and there's a plugin for detecting styling of scroll-bars. You can use it like the following

if (Modernizr.cssscrollbar) {  ... }
Peter O.
  • 28,965
  • 14
  • 72
  • 87
Juan Mendes
  • 80,964
  • 26
  • 138
  • 189