Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

199
Vistas
How to know device-type from JS Navigator object?

Is there a way to know device type - ex: mobile, tablet from Navigator API - https://developer.mozilla.org/en-US/docs/Web/API/Navigator?

about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

In a secure context, you can use navigator.userAgentData, which provides a NavigatorUAData object, which has some useful information about the user agent (browser), including a mobile flag. The getHighEntropyValues method returns a promise which will be fulfilled with more detailed information (if the user allows it) or rejected (if not, or the browser doesn't offer high-entropy values).

For platforms that don't support userAgentData (yet), you can fall back to parsing the userAgent string, but beware that the userAgent string is notoriously unreliable and easily spoofed.

about 4 years ago · Juan Pablo Isaza Denunciar

0

You can use the following function:

getDeviceType() {
        const ua = navigator.userAgent;
        const tabletRegex = /(tablet|ipad|playbook|silk)|(android(?!.*mobi))/i;
        const mobRegex = /Mobile|iP(hone|od)|Android|BlackBerry|IEMobile|Kindle|Silk-Accelerated|(hpw|web)OS|Opera M(obi|ini)/;

        if (tabletRegex.test(ua)) return "tablet";
        if (mobRegex.test(ua)) return "mobile";
        return "desktop";
    }
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda