var icon1 = new Image();
var wid1;
var hei1;
icon1.src = resource; // resource is Image URL here
icon1.onload = function () {
wid1 = icon1.width;
hei1 = icon1.height;
var rati = wid1 / hei1;
};
此代码用于计算宽度和高度的比率,以进一步保持图像的宽高比,但在IE上根本不起作用。还有什么我可以用来维护适用于所有浏览器的图像宽高比吗?