Forums Register Login

Using JavaScript to communicate with Applets

+Pie Number of slices to send: Send
I have an applet that is declared as follows in a JSP page.

<OBJECT classid="clsid:CAFEEFAC-0014-0002-0008-ABCDEFFEDCBA"
width="650" height="530" align="baseline"
codebase="http://java.sun.com/update/1.4.2/jinstall-1_4_2_08-windows-i586.cab">
<PARAM name="code" value="IPETETApplet.class">
<PARAM name="name" value="IPETET">
<PARAM name="id" value="IPETET">
<PARAM name="type" value="application/x-java-applet;jpi-version=1.4.2">
<PARAM name="archive" value="Sipetet.jar,SIPETETclient.jar,Swsse.jar,Swebserviceclient+ssl.jar,BST.jks">
No Java 2 SDK, Standard Edition v 1.4.2_08 support for APPLET!!
</OBJECT>


And a "test form" with one button in it as follows.


<form name="form2" action="">
<input type="submit" value="TestIt!" name="SubmitButton"
onKlick="testApplet()">
</form>

Note that I had to spell the above Javascript event as onKlick to get this message posted on JavaRanch.

Here is my Javascript function

function testApplet()
{
returnStr = document.applets[0].testUserHandler();
alert(returnStr);
return null;
}

In my applet, the method "testUserHandler()" just returns a string.

This all seems to work well (i.e. I see the ALERT window pop up with the correct text), *EXCEPT* that my applet's init() method is called after every invocation of my Javascript function testApplet(). How do I set up my application so that the applet's method is called, but the init() method isn't called?

Thanks in advance.
+Pie Number of slices to send: Send
That shouldn't happen. Are you sure you're not unintentionally calling the init() method from your applet code?
+Pie Number of slices to send: Send
I'm positive I'm not calling the init()) method.

And you're right, it shouldn't do that, which is why I'm asking if anyone else has seen this. If it helps, I'm using IE6.x as my browser.
+Pie Number of slices to send: Send
A WAG
Could it be that the browser is reloading the page after doing a "Submit" from a <form?
Try some tests by using a type=Button vs a type=submit and see what happens.
+Pie Number of slices to send: Send
That was it! If you use input type="submit", then if you don't supply an action the current page is reloaded.

Thanks!
Liar, liar, pants on fire! refreshing plug:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 1039 times.
Similar Threads
running applets on the local host: how to?
detect JVM
Object doesn't support this method or property-Error calling applets from javascript
JDK 1.5 Compiled Applet not working with JRE 1.4
Please HELP!! My 1.4.1_01 html always prompts me to install 1.4.1_01
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 20:10:35.