Firefox not calling an applet method

B

Blondie21

Hi,
I have a .jsp file in the following format:

.... html headers, jsp code, html code...

<jsp:plugin
type="applet"
code="path.in.packet.appletclassname.class"
codebase=".."
jreversion="1.5"
archive="packetname.jar"
height="0"
width="0"
name="appletname"<jsp:fallback>
<p>Unable to start the applet.</p>
</jsp:fallback>
</jsp:plugin>

.... html code...

<script type="text/javascript">
var theApplet = document.applets.appletname;
methodOutput = theApplet.callmethod();
document.write(methodOutput);
</script>

.... the rest of the html code ...

Javascript can call this method with IE 6.0, but with Firefox I get the
following message: "Error: theApplet has no properties".

And here is how Firefox and IE6.0 translate my <jsp:plugin> tag:

<OBJECT classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93"
name="appletname"
width="0" height="0"
codebase="http://java.sun.com/products/plugin/1.2.2/jinstall-1_2_2-win.cab#Version=1,2,2,0">;
<PARAM name="java_code" value="path.in.packet.appletclassname.class">
<PARAM name="java_codebase" value="..">
<PARAM name="java_archive" value="packetname.jar">
<PARAM name="type" value="application/x-java-applet;version=1.5">

<COMMENT>
<EMBED type="application/x-java-applet;version=1.5" name="appletname"
width="0"
height="0" pluginspage="http://java.sun.com/products/plugin/";
java_code="path.in.packet.appletclassname.class"
java_codebase=".."
java_archive="packetname.jar"
clientLocale="en_IE">
<NOEMBED>
</COMMENT>

<p>Unable to start the applet.</p>

</NOEMBED></EMBED>
</OBJECT>

I have already tried other solutions, like
document.getElementsByName() and
document.embeds ( as well as document.getElementsByID, but this could
never work with Firefox as, from what I found in google, Firefox does
not assume that applet name = applet id, what IE does).
Still, I never managed to call this method with Firefox.
Would anyone have any other ideas?

Thank you,

Blondie
 
M

Martin Honnen

Blondie21 wrote:

<script type="text/javascript">
var theApplet = document.applets.appletname;
methodOutput = theApplet.callmethod();
document.write(methodOutput);

To access an object like an applet in the DOM and be able to call its
methods the object needs to be loaded and intialized so your chance to
script an applet by putting the above code simply somewhere in the body
of the HTML document are very low as it is executed while the document
is loaded.
Put the applet in the HTML document and then use script in the onload
handler to try to script the applet. Of course that script can't do
document.write then but I guess that attempt above is only some poor
attempt at debugging.
Or place a button in the HTML document which in its onclick handler
tries to script the applet.

And here is how Firefox and IE6.0 translate my <jsp:plugin> tag:

<OBJECT classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93"

The browser does not translate any <jsp> tags at all, your server side
framework does that and then delivers HTML or HTML tag soup to the browser.
 
B

Blondie21

Martin said:
To access an object like an applet in the DOM and be able to call its
methods the object needs to be loaded and intialized so your chance to
script an applet by putting the above code simply somewhere in the body
of the HTML document are very low as it is executed while the document
is loaded.
Put the applet in the HTML document and then use script in the onload
handler to try to script the applet. Of course that script can't do
document.write then but I guess that attempt above is only some poor
attempt at debugging.
Or place a button in the HTML document which in its onclick handler
tries to script the applet.

Thank you for your answer.
No, I'm not using this for debugging.
I still don't understand why this works fine with IE. And what does DOM
have to do with it at all?

Thank you,
Blondie21
 

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,763
Messages
2,569,563
Members
45,039
Latest member
CasimiraVa

Latest Threads

Top