Current Position:Home > Java and java script communication

Java and java script communication

Update:10-11Source: network consolidation
how to access a javasript string variable in java

The Best Answer

If you are trying to access it from an applet you can do the following:
// call the html page
JSObject win = JSObject.getWindow(this);
JSObject doc = (JSObject) win.getMember("document");
JSObject loc = (JSObject) doc.getMember("location");     
String s = (String) loc.getMember("href");
String stringArg = "status from init()";     
Here win is the JSObject that gets the html page
stringArg is the object value that will be placed into the javascript var.
win.setMember sets the javascript var 'status' with the value placed in stringArg.
You will need to import
import netscape.javascript.*;