Solved

Javascript function call from Java

Posted on 1998-07-30
5
167 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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
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.

707 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

18 Experts available now in Live!

Get 1:1 Help Now