codemaster
12-02-2009, 12:39 AM
Hello,
I have a function that is supposed to create a class, but whenever it's run my browser is redirected:
If the current url is: "C:/Blah/ble.html"
Then I am redirected to: "C:/Blah/[object Object]"
And, of course, I get a problem loading the page because it doesn't exist.
My code is as follows:
function position(iX, iY) {
this.x = iX;
this.y = iY;
}I have debugged to the point that I know the last line
this.y = iY;is, indeed, run.
Also, I have checked that I do not reach the next statement after the function is called; it it called with this line:
this.location = new position(Math.random() * (document.width - this.size * 2) + this.size, Math.random() * (document.height - this.size * 2) + this.size);
Additionally, removing the "new" keyword from before the position does not help.
Why in the world would it redirect me?
I have a function that is supposed to create a class, but whenever it's run my browser is redirected:
If the current url is: "C:/Blah/ble.html"
Then I am redirected to: "C:/Blah/[object Object]"
And, of course, I get a problem loading the page because it doesn't exist.
My code is as follows:
function position(iX, iY) {
this.x = iX;
this.y = iY;
}I have debugged to the point that I know the last line
this.y = iY;is, indeed, run.
Also, I have checked that I do not reach the next statement after the function is called; it it called with this line:
this.location = new position(Math.random() * (document.width - this.size * 2) + this.size, Math.random() * (document.height - this.size * 2) + this.size);
Additionally, removing the "new" keyword from before the position does not help.
Why in the world would it redirect me?