1

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 ?

Aloras
  • 23
  • 5
  • *"if I use the eval method of JSObject to call foo.bar it works. but I don't want to use eval"* ..that seems a silly restriction. – Andrew Thompson Dec 04 '14 at 00:01
  • The eval solution gets problematic if one JS function gets user input. The user could change the syntax of evals string and execute code. To prevent this I would have to escape the input and I hope to avoid this extra work. – Aloras Dec 05 '14 at 16:14

0 Answers0