?
Solved

Javascript function call from Java

Posted on 1998-07-30
5
Medium Priority
?
215 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
[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
  • 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 200 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

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

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

Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
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 third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
The viewer will learn how to implement Singleton Design Pattern in Java.
Suggested Courses
Course of the Month15 days, 4 hours left to enroll

770 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