How to target the Blackberry browser?

user112793 picture user112793 · May 27, 2009 · Viewed 9.8k times · Source

I am using the following to target iphones, and handheld devices to use specific mobile styles sheets but the Blackberry browers is picking up only the regular screen style sheets.

<link media="handheld, only screen and (max-device-width: 320px)" href="mobile.css" type="text/css" rel="stylesheet" />
<link media="only screen and (max-device-width: 480px)" href="mobile.css" type="text/css" rel="stylesheet" />

All the other mobile devices I've tested the site on are picking up the correct style sheets.

Does anyone know a way to target the Blackberry browser to do the same?

Thanks!

Answer

edeverett picture edeverett · May 27, 2009

The state of mobile browsers is such a mess at the moment that I would not recommend trying to detect versions in the client. The most reliable way to do it is to use something like WURFL http://wurfl.sourceforge.net/ and do all your checking server side.

Good luck getting anything working nicely on the blackberry! Oh and don't forget to that the carriers might be screwing with your HTML before it even gets to the phone.