Skip to content Skip to sidebar Skip to footer

What's The Best Way To Detect A Webos Tablet With Jquery / Plain Js

I'm looking for the best way to detect a webOS tablet using plain JS and if it's any easier also using jQuery. The user agent of the tablet should look something like this: User-Ag

Solution 1:

Here's a function in PHP that will detect WebOS and any other mobile device you could need. Less than 1kb in code =)

functiondetectMobileDevice() {
    if(preg_match('/(android|avantgo|blackberry|bolt|boost|cricket|docomo|fone|hiptop|mini|mobi|palm|phone|pie|tablet|up\.browser|up\.link|webos|wos)/i', $_SERVER['HTTP_USER_AGENT'])) {
        returntrue;
    }
    else {
        returnfalse;
    }
}

if you want to do ONLY webOS, change line 2 to:

if(preg_match('/(webos)/i', $_SERVER['HTTP_USER_AGENT'])) {

to use:

if(detectMobileDevice()) {
    // If mobile device detected, do something
}
else {
   // Otherwise, do something else...
}

if you need more details, visit here: http://www.justindocanto.com/scripts/detect-a-mobile-device-in-php-using-detectmobiledevice

Solution 2:

I don't know if you can do any feature detection that'll only identify WebOS. It's WebKit-based, so all other WebKit-based platforms will have the same features. Looking at Zepto.js' source, they're doing exactly the same as you are:

ua.match(/(webOS|hpwOS)[\s\/]([\d.]+)/)

(The 2nd capture is the version)

From detect.js

Post a Comment for "What's The Best Way To Detect A Webos Tablet With Jquery / Plain Js"