0
首先,javascript newb在這裏和工作在一個小寵物項目上,試圖在這方面做得更好。我正在建立一個Image對象正在更新Javascript對象
function Image (id, name, height, width) {
this.id = id;
this.name = name;
this.height = height;
this.width = width;
}
業務的第一步是寫我可以做的id和名字。
var image = new Image(
json.revision_images[i].id,
json.revision_images[i].OrgImageName,
json.revision_images[i].galleryid
);
我的下一個步驟是將高度和寬度的對象的每個instatiation,這是在那裏我有包裝我的頭圍繞對象概念的問題。
我有一個小函數獲得了引用縮略圖的自然高度和寬度。
function checkImageDimensions (id)
{
var img = $("#" + id);
naturalDimension = getNatural(img);
}
如何去分配
this.height = naturalDimension.oHeight;
this.width = naturalDimension.oWidth;
基於ID的對象?
Image對象已經存在於瀏覽器環境中,你應該已經更改對象的名稱到另一個,順便說一句標準的Image對象有寬度,高度屬性 – kirugan
需要查看getNatural()函數的代碼,或者至少知道它是什麼樣的返回 –