According to Paul Irish, RIM said this:
Unfortunately, we had a problem with the build system during BlackBerry 6.0, which caused crashes that support WebKit touch, even for non-touch devices. It has long been fixed, but some public builds do have this problem.
See these (currently open) github / Modernizr tickets for possible workarounds and the latest detection code, and then try changing your plugin if necessary. You might need a specific blackberry detection if the latest detection code below does not work.
Also check this touch test , the browser tab shows that the blackberry 9000 was detected as false, so you should try to test it on your device too. http://modernizr.github.com/Modernizr/touch.html
The latest modernizr source for touch detection seems to add @media detection in addition to your code that you posted.
tests['touch'] = function() { var bool; if(('ontouchstart' in window) || window.DocumentTouch && document instanceof DocumentTouch) { bool = true; } else { injectElementWithStyles(['@media (',prefixes.join('touch-enabled),('),mod,')','{#modernizr{top:9px;position:absolute}}'].join(''), function( node ) { bool = node.offsetTop === 9; }); } return bool; };
BlackBerry / PlayBook UA sniffing
To specifically identify BlackBerry devices using the user agent string and borrow funds from here and here I hacked this little function that you can check and see while working on jsbin at http://jsbin.com/aliwur/1/edit#javascript , live , and it should parse Blackberry 5.0 / 4.0 / 6.0 and Playbook from user agent strings:
function rim_useragent_parser(ua) { var info = false, model = null, model_number = null, os_version = null; if (ua.indexOf("BlackBerry") >= 0) { if (ua.indexOf("Version/") >= 0) { // BlackBerry 6 and 7 model = ua.match(/BlackBerry\s[0-9]*/); if (model) { model_number = model[0].match(/[0-9]+/); pos = ua.indexOf("Version/") + 8; os_version = ua.substring(pos, pos + 3); info = { 'model' : model[0], 'model_number' : model_number[0], 'os_version' : os_version }; } } else { // BlackBerry Device Software 4.2 to 5.0 model = ua.match(/^BlackBerry[0-9]*/); if (model) { model_number = model[0].match(/[0-9]+/); var SplitUA = ua.split("/"); os_version = SplitUA[1].substring(0, 3); info = { 'model' : model[0], 'model_number' : model_number[0], 'os_version' : os_version }; } } } else if (ua.indexOf("PlayBook") >= 0) { // PlayBook model = ua.match(/RIM Tablet OS\s[0-9].[0-9].[0-9]/); if (model) { model_number = model[0].match(/[0-9].[0-9].[0-9]/); pos = ua.indexOf("Version/") + 8; os_version = ua.substring(pos, pos + 5); info = { 'model' : model[0], 'model_number' : model_number[0], 'os_version' : os_version }; } } return info; }
Of course, this may be more than you need to simplify it only to “Blackberry 9300 6.0”. I think you could just do this:
var ua = navigator.userAgent; if (ua.indexOf("BlackBerry") >= 0) { if (ua.indexOf("Version/") >= 0) { // BlackBerry 6 and 7 var model = ua.match(/BlackBerry\s[0-9]*/); if (model) { var model_number = model[0].match(/[0-9]+/); if (model_number) model_number = model_number[0]; pos = ua.indexOf("Version/") + 8; os_version = ua.substring(pos, pos + 3); if (os_version === '6.0' && model_number === '9300') { // do what you need specifically for this } } } }
For a better analysis of all User Agents, see ua-parser
https://github.com/tobie/ua-parser/