K
Kevin Newman
I have a situation, where I'd like to dynamically create a function in
the global space (window.funcWillGoHere) and have it call a method (or
private function) of an instantiated object that it will not know the
name of.
I came up with this:
dude = function() {
function dudely() {
alert('dudely');
};
eval('window.test=dudely');
};
$dude = new dude();
window.test();
window.test is a privileged method, except it is a method of another object.
The question is; Is this reliable? Can I expect it will work in the future?
It seems to work in current browsers, but I just want to make sure it
isn't some quirk that will stop working at some point in the future.
Thanks,
Kevin N.
the global space (window.funcWillGoHere) and have it call a method (or
private function) of an instantiated object that it will not know the
name of.
I came up with this:
dude = function() {
function dudely() {
alert('dudely');
};
eval('window.test=dudely');
};
$dude = new dude();
window.test();
window.test is a privileged method, except it is a method of another object.
The question is; Is this reliable? Can I expect it will work in the future?
It seems to work in current browsers, but I just want to make sure it
isn't some quirk that will stop working at some point in the future.
Thanks,
Kevin N.