By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,600 Members | 1,861 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,600 IT Pros & Developers. It's quick & easy.

Calling Java method from Javascript

P: n/a
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?

--
Linux Home Automation Neil Cherry nc*****@comcast.net
http://home.comcast.net/~ncherry/ (Text only)
http://hcs.sourceforge.net/ (HCS II)
http://linuxha.blogspot.com/ My HA Blog
Oct 8 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a


Neil Cherry wrote:
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();
}

--

Martin Honnen
http://JavaScript.FAQTs.com/
Oct 8 '05 #2

P: n/a
On Sat, 08 Oct 2005 19:51:49 +0200, Martin Honnen wrote:


Neil Cherry wrote:
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();
}


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.

--
Linux Home Automation Neil Cherry nc*****@comcast.net
http://home.comcast.net/~ncherry/ (Text only)
http://hcs.sourceforge.net/ (HCS II)
http://linuxha.blogspot.com/ My HA Blog
Oct 9 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.