Is there a possible way to check the aspect ratio of a website user's screen (4:3, 16:9 etc.) in JavaScript or other web languages?
Asked
Active
Viewed 730 times
0
-
What do you mean "of a user"? Pants size? Are you asking about the physical screen size, or the browser viewport? – isherwood Nov 27 '14 at 18:15
-
i basically mean the resolution of their screen size and how to check if its a 4:3 screen or 16:9 etc – Shigetora Nov 27 '14 at 18:17
-
You don't have access to the hardware dimensions. – isherwood Nov 27 '14 at 18:18
-
well i think the browser viewport is always the same size so you can calculate it. but then, how can i check their browser viewport? – Shigetora Nov 27 '14 at 18:19
-
2That's a question that has been asked and answered many times on SO. – isherwood Nov 27 '14 at 18:20
-
Do you want the aspect ratio of the browser or the screen, there's a difference ? – adeneo Nov 27 '14 at 18:21
-
1Keep in mind this value can change wildly if they're on a device with variable orientation like a tablet or a phone. – tadman Nov 27 '14 at 18:22
1 Answers
1
This two variables will give you height and width, which can be used to get resolution or aspect ratio:
var width = screen.width;
var height = screen.height;

Suri
- 66
- 6