Solved

Javascript function call from Java

Posted on 1998-07-30
5
181 Views
Last Modified: 2010-04-16
How do I make a call to a Javascript function without using JSObject? I need to send a string parameter to the function.
I tried creating the following URL:

URL url = new URL("javascript:top.funcName(\"" + varName + "\");");

in order to call getAppletContext().showDocument(url), but I get a MalformedURLException.
0
Comment
Question by:dmontes
  • 2
  • 2
5 Comments
 
LVL 4

Expert Comment

by:evijay
ID: 1229259
why do you want to use javascript without live connect (i mean JSObject)

0
 

Author Comment

by:dmontes
ID: 1229260
I don't want to rely on the JSObject class when my applet will work on IE4. Besides, the showDocument method should work on both IE4 and Netscape4 (or at least that's what the June/July issue of the JavaPro magazine says, page 66).
0
 
LVL 2

Accepted Solution

by:
bernfarr earned 100 total points
ID: 1229261
dmontes

I assume what you're trying to do is have the JavaScript execute and give you a string result that is a URL? The list of URL alternatives is contained within the function in your HTML page.

If so, is it possible to pass the likely URL(s) in as parameter values to your applet? Then you can evaluate varName within your applet and pick the resulting URL from those passed in.

0
 

Author Comment

by:dmontes
ID: 1229262
No, I don't need a value back from the JavaScript function. I do need to send a parameter TO the JS function (in the example, I'm using String varName). The URL class used in the example is simply the way to access the JavaScript function.
0
 
LVL 2

Expert Comment

by:bernfarr
ID: 1229263
Can you explain a little more what you're trying to accomplish? It may be that it can be done using just JavaScript, without requiring some Java code.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

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 Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.

910 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

20 Experts available now in Live!

Get 1:1 Help Now