我想要讀取由for-loop中的url指定的圖像的寬度(orgWidth),計算其高度爲480px的新寬度(calcWidth)。獲取由URL指定的圖像的寬度jquery
for (var i=1; i <= item.length; i++) {
url = document.images[i].rsc;
orgWidth = some-fancy-thing-that-reads-the-width;
orgHeight = some-fancy-thing-that-reads-the-height;
factor = orgHeight/480 // 1400/480 = 2.916
calcWidth = orgWidth/factor // 1000/2.916 = 342.935
document.images[i].width = calcWidth;
}
頁我需要它: http://foto.hendrik-schicke.de/index.php/people
你可能想看看http://stackoverflow.com/questions/1643858/image-native-width-in-jquery – 2011-12-26 15:06:24