Solved

LiveConnect

Posted on 1997-08-04
3
374 Views
Last Modified: 2010-05-18
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.JSObject 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?.
0
Comment
Question by:wojsoft
  • 2
3 Comments
 
LVL 4

Expert Comment

by:rembo
ID: 1224350
Here's an example of how to access the JavaScript from
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("JavaScript error msg: " + e.getMessage());
           
        }
      
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

0
 

Author Comment

by:wojsoft
ID: 1224351
What is this parent parameter?
Function getWindow() is defined like below:
public static JSObject getWindow(Applet applet)
0
 
LVL 4

Accepted Solution

by:
rembo earned 100 total points
ID: 1224352


Sorry about that, the parent variable is the Applet which
I passed into this class.  So, if you have this inside
your applet class just pass in the 'this' variable.

-Tony


0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
hibernate jars 4 45
JAVA API design with micro service cloud in mind 1 47
how to debug htl and js pages 8 39
Notify sent to other threads in Java 9 33
For customizing the look of your lightweight component and making it look lucid like it was made of glass. Or: how to make your component more Apple-ish ;) This tip assumes your component to be of rectangular shape and completely opaque. (COD…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.

828 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question