Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

187
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!