有没有从当前监视器获取aspectRatio的方法?
我已经测试了以下代码,它可以与Firefox一起运行,但不适用于Internet Explorer ...
//calculate Aspect Ratio
int gcd= gcd(getScreenWidth(),getScreenHeight());
aspectRatio=getScreenWidth()/gcd+":"+getScreenHeight()/gcd;
......
}
public static native int getScreenWidth() /*-{
return $wnd.screen.width;
}-*/;
public static native int getScreenHeight() /*-{
return $wnd.screen.height;
}-*/;
/**
* Euclidean algorithm to calculate the gcd
* @param a number 1
* @param b number 2
* @return the gcd of both numbers
*/
public int gcd (int a, int b) {
return (b == 0) ? a : gcd (b, a%b);
}
$wnd.screen.height
在ff中运行正常,但在IE(9.0)中,它返回的值高于真值...是否有其他方法可以获得当前的aspectratio?
格尔茨, 命运