A
Aaron
Hi,
I've seen javascript code where a constructor function is passed an argument
"document", and inside the function itself the assignment "this.document =
document;" is made. This is the code (or the part necessary for the
example):
function ToggleButton(document) {
ToggleButton.images = new Array(4);
for(i=0;i<4;i++) {
ToggleButton.images = new
Image(ToggleButton.width,ToggleButton.height);
ToggleButton.images.src = ToggleButton.imagenames;
}
this.document = document;
var index = document.images.length;
}
I don't understand the "this.document = document" part...is it possible to
assign the property of the main window (the global object here) to an
object, in effect making the object equal to the main window? Does anyone
have an explanation for me as to why this works?
Thanks,
Aaron
I've seen javascript code where a constructor function is passed an argument
"document", and inside the function itself the assignment "this.document =
document;" is made. This is the code (or the part necessary for the
example):
function ToggleButton(document) {
ToggleButton.images = new Array(4);
for(i=0;i<4;i++) {
ToggleButton.images = new
Image(ToggleButton.width,ToggleButton.height);
ToggleButton.images.src = ToggleButton.imagenames;
}
this.document = document;
var index = document.images.length;
}
I don't understand the "this.document = document" part...is it possible to
assign the property of the main window (the global object here) to an
object, in effect making the object equal to the main window? Does anyone
have an explanation for me as to why this works?
Thanks,
Aaron