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

188
Vistas
get screen size in inches in javascript

Hi guys I have a page that I want to set the initial zoom a little lower on smaller screen sizes, the problem is that I can't get the screen size within javascript, I need to zoom out on screens between 13 and 14 inches but there is no logical way to get that from the pixel values

I have the same problem on mobile, on certain phones the page looks good but on others it doesn't, instead of rebuilding everything I just wanna zoom out

I know it might be bad practice but if there is a way to do it that's what I wanna do

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

0

Inspired by what bZezzz wrote, but with some code to retrieve actual screen dimensions. Also note that screen.availHeight and screen.availWidth return the screen size, and might not be that helpful if your page is being rendered on only a part of the screen.

let hypotenuse = Math.sqrt(screen.availHeight**2 + screen.availWidth**2)
console.log(
  'pixels', hypotenuse,
  'inches', hypotenuse / 96 // Per spec, there are 96 pixels per inch
);

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