-3

How can I tell using PHP, CSS or javascript if a monitor is standard (square) or widescreen?

ghan
  • 525
  • 11
  • 24

1 Answers1

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