tags:

views:

67

answers:

2

I need to make 3:4 window, where 3 is 75% of screen. How could i set width? Like if i have 100px height and 10000000000000px width monitor, than i shold have 75:100px window.

I heard that it could be done with the help of Javascript.

+2  A: 

75*(4/3) //or any other ratio

width * (reversed ratio)

function getWidth(height, ratioInPercentage)
{
    return height*(ratioInPercentage/100);
}

use:

width = getWidth(100,75);
jfrobishow
And where should i write this?
TRAVA
It's not exactly a full code sample. It just says "multiply width by the ratio."
Matchu
Which is pretty much what the OP asked for. Given more details, a more complete solution could be provided.
jfrobishow
Question being about calculation, not implementation wasn't clear to me - downvote removed.
Matchu
A: 

window.resizeTo function will allow you to resize the window.
IE supports this if your page is the only tab in the window.
Chrome doesn't support this.

You can use screen.width and screen.height to get the screen dimension

ItzWarty
So how should I wright it and where?
TRAVA
note: screen.width and .height refer to the whole screen, not to the browser window. You may actually want window.innerWidth and .innerHeight . (I'm aware that the OP asked for screen dimensions, but that's not a very useful measurement)
Piskvor
note: window.innerWidth isn't supported by all browsers, which makes this living hell. You'll have to write browser-specific JS.
ItzWarty