Calling Java method from Javascript

N

Neil Cherry

I've done a fair amount of searching on this subject and I can call
my Java methods with Javascript if I use the <applet></applet> tags
but when I switch over to <object></object> tags I'm not longer able
to call my Java method, instead I get:

Error: document.CameraViewer.setInterval is not a function

How does one use the object tags and call Java methods?
 
M

Martin Honnen

Neil said:
I've done a fair amount of searching on this subject and I can call
my Java methods with Javascript if I use the <applet></applet> tags
but when I switch over to <object></object> tags I'm not longer able
to call my Java method, instead I get:

Error: document.CameraViewer.setInterval is not a function

Use
<object id="applet1" ...></object>
then try e.g.
var applet = document.getElementById('applet1');
if (applet && typeof applet.publicJavaMethodName != 'undefined') {
// now call method e.g.
applet.publicJavaMethodName();
}
 
N

Neil Cherry

Use
<object id="applet1" ...></object>
then try e.g.
var applet = document.getElementById('applet1');
if (applet && typeof applet.publicJavaMethodName != 'undefined') {
// now call method e.g.
applet.publicJavaMethodName();
}

Thanks, initially this didn't help. It turned out I had written the
<object></object> section incorrectly and ended up with an object
inside an object with the same name. I reordered it and the code
sample you provided works fine. Thanks.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,575
Members
45,053
Latest member
billing-software

Latest Threads

Top