Solved

LiveConnect

Posted on 1997-08-04
3
390 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

Question has a verified solution.

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

This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:

624 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