Given an Applet in one frame in a multi-frame web application where all frames are loaded from the same web server, how can that Applet invoke JavaScript methods in other frames? I tried something like this:
jsobject.call("parent.otherFrame.methodToCall", new String[] {"argument"});
and I get a complaint that the function does not exist. However, if I invoke it like this:
jsobject.eval("parent.otherFrame.methodToCall('argument')");
then it works. I'm trying to avoid use of eval
. Is calling code via call
in a different frame from an Applet something that is likely to have different behavior in each browser and JVM combination? Is eval
safer as it is evaluated in the JavaScript engine rather than partly on the Applet side?
The equivalent code without eval is probably something like this:
jsobject = (JSObject)jsobject.getMember("parent");
jsobject = (JSObject)jsobject.getMember("otherFrame");
jsobject.call("methodToCall", new String[] {"hello!"});