[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 226
  • Last Modified:

Javascript function call from Java

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
dmontes
Asked:
dmontes
  • 2
  • 2
1 Solution
 
evijayCommented:
why do you want to use javascript without live connect (i mean JSObject)

0
 
dmontesAuthor Commented:
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
 
bernfarrCommented:
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
 
dmontesAuthor Commented:
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
 
bernfarrCommented:
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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now