Unfortunately, the behavior you mentioned is exactly what we see in browsers nowadays.
You can hide the applet, but simply hiding its parent div won't do the trick.
To achieve this, separate the web UI elements from the applet's div. You can hide the web UI elements using "display: none" as you described. To hide the Java applet, set the style to "width: 0px; height: 0px" on the applet element.
Remember to set the width and height of the applet's style, not the attributes.
An example of a hidden applet element:
<applet id="myHidableApplet"
width="600px" height="400px"
style="width: 0px; height: 0px;">
A visible group example:
<div id="group1">
<applet id="group1applet"
width="600px" height="400px"
style="width: 600px; height: 400px;">
<param> etc... </param>
</applet>
<div id="group1ui" style="display: block">
<input name="Name" type="text" />
</div>
</div>
When hiding the group, transform it like this:
<div id="group1">
<applet id="group1applet"
width="600px" height="400px"
style="width: 0px; height: 0px;">
<param> etc... </param>
</applet>
<div id="group1ui" style="display: none">
<input name="Name" type="text" />
</div>
</div>
This distinction between element attributes and style attributes was discovered while trying to deploy a hidden applet for JavaScript interactions without a UI. This approach is sometimes known as JAHA (JavaScript And Hidden Applet).
Key points to remember:
- The <div> containing the applet must be visible for the applet to load.
- <applet width="0px" height="0px" > will not load properly in Chrome.
- Setting "display: none" on the applet's <div> will cause the applet to unload.
- Setting attributes width=0 and height=0 on the <applet> will also cause the applet to unload in Chrome.
- Using .style.width and .style.height is essential for making the <applet> invisible.