• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Javascript interaction with an applet, but what if I can't use the APPLET tag?

 
Ranch Hand
Posts: 140
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
All,

I've got a web-page based application that primarily works with Javascript and HTML, but uses a java applet in the page for certain types of work.

So the applet is in the page with an actual APPLET tag. If the Javascript needs to get the applet to do something, or get some information from the applet, I use the following:

document.applets[0].funcName(params)


However, now there's rumbling from the decision-makers as to whether or not we should move from using the APPLET tag to using OBJECT and EMBED tags.

Unfortunately, a quick attempt at that shows that, surprise surprise, when I use either OBJECT (for IE) or EMBED (for everything else), I get a Javascript error saying that document.applets[0] has no properties.

The convenient thing was that, for non-IE, I could just substitute "document.embeds[0]" in place of "document.applets[0]" and it works.

Not so with OBJECT for IE.

So, is there an equivalent that can be used when/if I have to use the OBJECT tag for IE?

Thanks in advance...


EDIT: Ok, I'm kind of a doofus here - although it didn't work the first time I tried it so I'm convinced the browser's conspiring against me. My results:

IE: OBJECT tag, use document.applets[0].funcName
Firefox: EMBED tag, use documents.embeds[0].funcName
Opera: EMBED tag, both applets[0] and embeds[0] work.


I don't suppose there's some universal sort of keyword here instead of embeds or applets that'll work on everything, is there?
[ January 17, 2007: Message edited by: Joe Vahabzadeh ]
 
author and iconoclast
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Let's move this to "HTML and JavaScript" so the JavaScript gods will smile upon you.
 
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can you just give the object an ID and reference that instead with:

document.getElementById("myId").

Eric
 
Eric Pascarello
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
if that does not work you can try object detection



Eric
 
Joe Vahabzadeh
Ranch Hand
Posts: 140
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Eric,

Thanks for the suggestions.

For the first solution - works in Firefox, but not IE6 or Opera (don't have access to the Mac today to test against Safari)

Looks like if management insists on conversion to OBJECT/EMBED that I'll have to go with your second solution - but I'm trying to convince them to simply keep using the APPLET tag - I don't see any real benefit to switching from APPLET over to OBJECT/EMBED, but I'll admit that I don't know a whole lot about the distinction between the two methods.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic