wojsoft
asked on
LiveConnect
My problem concern on communication between JavaScript and Java in Netscape Navigator or Communicator.
In the LiveConnect documentation has been written:
"Before you can access JavaScript, you must get a handle for the Navigator window. Use the getWindow method
in the class netscape.javascript.JSObje ct to get a window
handle, passing it the Applet object."
I need derive from JS some information about connection
(location.port, location.host),but I have no applet,
only Java object created in JS:
<script>
navigator.myobject =Packages.JSTest();
</script>
thus I cannot call like inside applet:
JSObject win = JSObject.getWindow(this);
How can I access JavaScript objects and its properties???.
Is it possible?.
In the LiveConnect documentation has been written:
"Before you can access JavaScript, you must get a handle for the Navigator window. Use the getWindow method
in the class netscape.javascript.JSObje
handle, passing it the Applet object."
I need derive from JS some information about connection
(location.port, location.host),but I have no applet,
only Java object created in JS:
<script>
navigator.myobject =Packages.JSTest();
</script>
thus I cannot call like inside applet:
JSObject win = JSObject.getWindow(this);
How can I access JavaScript objects and its properties???.
Is it possible?.
ASKER
What is this parent parameter?
Function getWindow() is defined like below:
public static JSObject getWindow(Applet applet)
Function getWindow() is defined like below:
public static JSObject getWindow(Applet applet)
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Java:
JSObject win = null;
JSObject doc = null;
if (url == null)
return;
try {
win = JSObject.getWindow(parent)
win.eval(url + ";");
} catch (Exception e) {
System.out.println("JavaSc
}
If you want to access generic JavaScript objects from there,
just do the eval of the command you want to execute on that
page. You can also access Java from JavaScript, but I'm
a little uncluear on what your actual question is.
-Tony