How to detect tablet, mobile, desktop, tv using javascript [closed]

I am developing an web application where I need to detect the device from javascript. Could anybody tell me whats the best way to do it ? I found several solution by googling. But no one is full proof. I do not want to use server side detection like WURFL.

My update

I am detecing device by matching CSS media queries using javascript. For media query matching using polyfill by Paul Irish



I advise you check out

In a nutshell, if you import a tiny JS file:

<script type='text/javascript' src="//"></script>

you will be left with a JSON object that looks like:

 "complete_device_name":"Google Nexus 7",

(that's assuming you are using a Nexus 7, of course) and you will be able to do things like:

if(WURFL.form_factor == "Tablet"){

This is what you are looking for.

Disclaimer: I work for the company that offers this free service. Thanks.


You can use:

1) JS: Detect by user agent

if (navigator.userAgent.match(/Android|BlackBerry|iPhone|iPad|iPod|Opera Mini|IEMobile/i))

Take the user agent strings from here:

2) CSS: Use responsive design

3) JS: Detect the screen width by screen.width


Recent Questions

Top Questions

Home Tags Terms of Service Privacy Policy DMCA Contact Us

©2020 All rights reserved.