Solved

Javascript function call from Java

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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
numbers ascending pyramid 101 191
how do i compare an object based on two fields 6 53
How to convert String matching to regex in java 4 30
login jsp example 24 46
Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
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 learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
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 …

813 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