Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get native screen resolution using jQuery

I'd like to get the native screen width on a device to append scripts in the DOM. Is it possible using jQuery ?

Thanks

like image 650
thomas-hiron Avatar asked Dec 23 '12 11:12

thomas-hiron


2 Answers

window.screen.width? Source: https://developer.mozilla.org/en-US/docs/DOM/window.screen

like image 115
Christian Avatar answered Nov 05 '22 03:11

Christian


Sure. You can get the basic width and height using:

screen.width;
screen.height;

If required, you can also get the pixel ratio (useful if you need to also detect retina displays) by using:

window.devicePixelRatio
like image 6
BenM Avatar answered Nov 05 '22 05:11

BenM