JSObject.call don't seem to work with Javascript namespaces

408 Views Asked by At

I have a Java Applet which uses some Javascript functions which are declared in an Javascript Object.

The Javascript looks like this

            var foo ={
            bar: function( var) {
            //do stuff
            }};

The Applet is loaded after the Javascript Object has been created. The function is callable if I use the Javascript console. I use the following call

foo.bar.("something"); 

my Applet uses the call method of JSObject

    Object[] args = { "something" };
    win.call("foo.bar", args);

This results in an Exception.

netscape.javascript.JSException: No such method "foo.bar" on JavaScript object

if I use the eval method of JSObject to call foo.bar it works. but I don't want to use eval

Is there a way to make the call method work as expected so that I can use a Javascript object to structure my code ?

0

There are 0 best solutions below