Solved

LiveConnect

Posted on 1997-08-04
3
364 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

Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
advertisement module in core php 4 162
javap bin 2 34
Java exception bubble up 2 18
JAVA API design with micro service cloud in mind 1 16
For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

773 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