How can I tell using PHP, CSS or javascript if a monitor is standard (square) or widescreen?
Asked
Active
Viewed 81 times
-3
-
1Did you try in any of those languages already? What was your attempt? – man0v Feb 24 '18 at 21:21
-
2the question here is "why"? – Funk Forty Niner Feb 24 '18 at 21:38
-
I've never seen a monitor with a square resolution, so I doubt that one could be considered "standard". – ChrisGPT was on strike Feb 25 '18 at 02:14
-
This looks like an [XY problem](https://meta.stackexchange.com/questions/66377/what-is-the-xy-problem). What are you trying to accomplish? – ChrisGPT was on strike Feb 25 '18 at 02:15
1 Answers
0
Hope this answers your question. You could try doing this is Javascript. First, find a common denominator for your width and height:
function commonDenom (width, height) {
return (height == 0) ? width : commonDenom (height, width % height);
}
Then plug in your screen width and height, and then get your aspect ratio:
var w = screen.width;
var h = screen.height;
var d = commonDenom(w,h);
var ratio = w/d + ":" + h/d;
From there I guess you could match strings. Hope that helps

Tiki
- 463
- 4
- 9