Solved

LiveConnect

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
wordappend challenge 8 84
ArrayIndexOutOfBoundException 9 30
eclipse java  build path 6 18
github account with ecipse 1 15
Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues undeā€¦
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
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:
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.

708 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now