这是我到目前为止所拥有的:http: //jsfiddle.net/nxCFn/
var il = new ImageLoader();
function ImageLoader() {
this.n = 2;
this.load = function() {
//obviously, the this = the image and not the original instance of ImageLoader :(
this.n++;
console.log(this.n);
}
this.imgnam = "http://www.google.com/images/errors/logo_sm.gif";
this.img = new Image();
this.img.src = this.imgnam;
this.img.onload = this.load;
}
因为图像是.load()
this
从load
点调用图像。我想this
从加载点到ImageLoader
它“属于”的实例。