views:

318

answers:

2

In IE in the ff. code, the catch clause is entered if someMethodThatThrowsExceptions does throw an exception. However, this is not the case in Firefox. Is this a limitation in Firefox's Javascript engine or LiveConnect implementation? Does a workaround exist?

try {
  document.applets["someApplet"].someMethodThatThrowsExceptions();
} catch (e) {
  handleError();
}
A: 

use

document.getElementById('someApplet').someMethodThatThrowsException()
Sergey Kovalenko
The problem is not with the reference to someApplet. Rather, it is with the catching of the exceptions being thrown by someMethodThatThrowsExceptions.
Chry Cheng
are you sure, someMethodThatThrowsException() executes in FF? Than ok, my answer is wrong. But anyway, why are you using applets.['applet_name'] instead getElementById?
Sergey Kovalenko
Yes, I'm sure the method executes in FF because I see the stack trace in the console.I'm using the applets property because it makes it seem clearer that the object you are referencing is an applet and not an HTML element customized with extra functions.
Chry Cheng
+1  A: 

Checked where I should have checked in the first place: https://developer.mozilla.org/en/LiveConnect. Found out that this is a known problem in a certain LiveConnect version. Discussion, solution and work-around here: http://forums.java.net/jive/thread.jspa?threadID=45933&tstart=0.

Chry Cheng