Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Joe Vahabzadeh
Ranch Hand
Posts: 140
  • Mark post as helpful
  • send pies
  • 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 ]
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24208
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Let's move this to "HTML and JavaScript" so the JavaScript gods will smile upon you.
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • 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
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • 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
  • 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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic