[thelist] JavaScript pointers

Andreas Wahlin Andreas.Wahlin at ufl.gu.se
Tue Jul 6 06:35:28 CDT 2004


I know javascript has pointers, but is there no way to force it to use
pointers in declarations?
I want to use window.onload as an argument to a function, but I just get
a call by value, not by reference.
An even simpler example is this:

var test = window.onload;
window.onload = function() { window.status = "YO"; };
alert(test);

Test will not have recieved the new function and alerts as "undefined".
What I'd like is something like

var test = pointer(window.onload);
window.onload = function() { window.status = "YO"; };
alert(test);

And then alert would yield "function() { window.status = "YO"; };"
Is this impossible? Is there some form of elaborate hack?

Andreas


More information about the thelist mailing list