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

145
Views
Javascript media queries not working in safari / iOS

Hope someone can help.

The following lines of code work in everything except Safari.

 if(window.matchMedia('(resolution:320dpi)').matches){res = i;}
 if(window.matchMedia('screen and (resolution:320dpi)').matches){wkres = I;}

Has anyone else discovered how to get Safari to recognise / process these queries? Any and all help gratefully received.

about 4 years ago · Santiago Gelvez
1 answers
Answer question

0

Safari does not support resolution, though it looks like the relevant bug has been fixed so it'll come out at some point in a Safari release.

It does support window.devicePixelRatio, though, which tells you the ratio of device pixels to CSS pixels (96ths of an inch).

So for the resolution part of that, you can use something along these lines:

const is320dpiOrMore = (window.devicePixelRatio * 96) >= 320;
about 4 years ago · Santiago Gelvez 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!