Skip to content
Advertisement

Tag: screen-resolution

How to detect the screen resolution with JavaScript?

Is there a way that works for all browsers? Answer original answer Yes. update 2017-11-10 From Tsunamis in the comments: To get the native resolution of i.e. a mobile device you have to multiply with the device pixel ratio: window.screen.width * window.devicePixelRatio and window.screen.height * window.devicePixelRatio. This will also work on desktops, which will have a ratio of 1. And

Advertisement