| re: priveledged stranger?
Kevin Newman wrote:[color=blue]
> 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');[/color]
The eval call is redundant:-
window.test = dudely;
- will work exactly the same, and so just as well. Generally, if an eval
call contains a string literal then it can be replaced with the code
equivalent of that string.
[color=blue]
> };
> $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?[/color]
<snip>
You can expect it to work with all ECMA 262 3rd edition implementations
operating in web browser environments (because the - window - identifier
is not part of javascript but is instead provided by the browser
environment).
Richard. |