0
我有問題的寬度和高度。寬度和高度undefined - Javascript/jQuery
我的功能:
function testImageSize(testSrc) {
var imageTestLink = "";
var link = testSrc.attr("src");
link = link.replace("/thumbs/", "/images/");
imageTestLink = link.replace(".thumb", "");
var theImage = new Image();
theImage.src = imageTestLink;
console.log(imageTestLink);
var rw = theImage.width;
var rh = theImage.height;
console.log(rw, rh);
}
我的問題是,當我運行這個功能imagesTestLink
總是返回正確的鏈接到圖像。但是rw
和rh
有時會在控制檯中返回0 0
值。有人可以幫我解決這個問題嗎?我已經閱讀了很多主題,但我沒有找到我的答案。
問候, Fantazy