Reputation: 948
I'd like to get the native screen width on a device to append scripts in the DOM. Is it possible using jQuery ?
Thanks
Upvotes: 5
Views: 33240
Reputation: 35950
You should use:
window.screen.availHeight
window.screen.availWidth
Upvotes: 1
Reputation: 53208
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
Upvotes: 6
Reputation: 35829
You can set the width to device width with a css property:
width: device-width;
Upvotes: 1
Reputation: 19750
window.screen.width
? Source: https://developer.mozilla.org/en-US/docs/DOM/window.screen
Upvotes: 12