Skip to content Skip to sidebar Skip to footer

Pass A Value To Javascript From Java

I have the following Java applet. It gets the absolute file path of a file that a user has selected: import java.awt.*; import java.awt.event.*; import java.io.*; import javax.swin

Solution 1:

You should look into using LiveConnect, which allows an applet to interact with JavaScript in a page, and vice versa.

The following code calls the global JavaScript function setPath in the page with a single argument:

netscape.javascript.JSObject.getWindow(appletInstance)
    .call("setPath", new Object[] { path });

The applet must be started with the parameter mayscript set to either true or mayscript to be allowed to use LiveConnect.


Post a Comment for "Pass A Value To Javascript From Java"