How do you call a JavaScript function from a Java applet

I have an Applet that needs to run on the following platforms: Internet Explorer (Windows-NT, Windows -2000), Netscape (Windows-NT, Windows-2000, Sun(Solaris), RedHat(Linux), HP(11.0), IBM(AIX)).

The Applet needs to call a JavaScript function that is included on the HTML page that contains the applet. In JRE-1.3.1 I used the AppletContext.showDocument(url,"_self" ) where the url is "javascript:MyScript('param1')". This works just fine. I tried using showDocument without the second parameter and all the other choices for the second parameter and none of them worked (nothing happened).

I tried the same code with JRE version 1.4-beta. It seems that version 1.4-beta no longer supports a URL that starts with "javascript" in the AppletContext.showDocument(url,"_self" ) method. The error is:

netscape.javascript.JSException: call does not support self.open

at sun.plugin.javascript.navig.Window.call(Unknown Source)

at sun.plugin.ActivatorAppletContext.showDocument(Unknown Source)

I tried to catch the JSException but I cannot seem to.

I then tried a completely different approach. I then grabbed the JSObject for the page and tried to call my javascript function (MyScript) directly:

JSObject theObj = JSObject.getWindow(this);

Object paramArray[] = new Object[1];

paramArray[0] = Param1;

theObj.call("MyScript", paramArray);

This worked fine on Netscape[Windows-NT, Windows-2000]. HP throws a JSException on getWindow() and Solaris just hangs. I did not even try IE.

What is the recommended approach here?

[1607 byte] By [jwatrous] at [2007-9-26 2:39:10]
# 1
you can try this, it worked for me: JSObject win = JSObject.getWindow(this);win.eval(function_call);I have other ways also, so if this doesn't work, let me know.
tapodaca at 2007-6-29 10:11:20 > top of Java-index,Desktop,Deploying...
# 2
I had already tryed .eval and it works fine on Windows. I can not get past JSObject.getWindow on Solaris or HP.
jwatrous at 2007-6-29 10:11:20 > top of Java-index,Desktop,Deploying...
# 3
I am a little busy at the moment, let me look for my solutions and get back to you.
tapodaca at 2007-6-29 10:11:20 > top of Java-index,Desktop,Deploying...