# JS- how to calculate a rectangle's ratio?

**URL:** <https://forum.kirupa.com/t/js-how-to-calculate-a-rectangles-ratio/296833>\
**Category:** web dev\
**Created:** [September 21, 2009, 4:19pm UTC](https://forum.kirupa.com/t/js-how-to-calculate-a-rectangles-ratio/296833 "2009-09-21T16:19:52Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![hroth](https://avatars.discourse-cdn.com/v4/letter/h/8e8cbc/32.png) [@hroth](https://forum.kirupa.com/u/hroth)\
**Post date:** [September 21, 2009, 4:19pm UTC](https://forum.kirupa.com/t/js-how-to-calculate-a-rectangles-ratio/296833/1 "2009-09-21T16:19:52Z")

</div>

Hi there,

How do I calculate the height of a rectangle that has is 16:9 from only the width?  
More specifically, how do I calculate it using JavaScript 🙂

Is there a standard way to determine the browser and do an if - else in javascript. I want to change the browser window but the behaviour is different with IE. So I need a if IE do this else do that.

tnks!!

-hroth
