The problem is as follows: An applet program is embedded into a JSP page via a tag. Inside the applet's `init()` method, it calls a JavaScript function on the page named `show()`, which sets the `display` style of the div containing the applet to `" "` (initially set to `display:none`). The purpose of this is to only display the applet on the page after its image has been fully drawn. In Internet Explorer (IE), the applet image displays correctly, but in Firefox, it does not show.
### JSP Page:
```html
...
```
### Applet Program:
```java
public void init() {
...
// Call the JavaScript function to set the visibility of the chart
JSObject.getWindow(this).eval("javascript:show()");
}
```
Why doesn't the applet image display in Firefox?
### Additional Information:
In the applet program, after the image is drawn, it calls the JavaScript function from the JSP page to change the `display` state of the div containing the `` tag to `" "` (initially set to `display:none`). However, the test results indicate that in Firefox, the applet does not call the JavaScript function, so the applet image does not display. This issue does not occur in IE.
Is there no one to answer? I'll continue waiting for an expert to provide a solution.
---
### Solution Reference:
You can refer to:
[How to pop up an advertisement window in IE from an applet](http://www.myexception.cn/java-web/33709.html)
### Related Articles:
- Java environment variable settings
- UC Browser encountering issues with WAS V7
- Java environment variable settings
---
### Analysis and Possible Solutions:
1. **Browser Compatibility Issues**:
Firefox may have stricter security policies compared to IE, especially regarding JavaScript interactions with applets. Ensure that the `JSObject` class is properly imported (`netscape.javascript.JSObject`) and that the browser supports the required functionality.
2. **JavaScript Syntax**:
In Firefox, the syntax `"javascript:show()"` might not work as expected. Instead, try directly invoking the function:
```java
JSObject.getWindow(this).call("show", new Object[] {});
```
3. **Applet Initialization Timing**:
The `init()` method might be executed before the DOM is fully loaded in Firefox. To address this, you can delay the call to the JavaScript function using a timer:
```java
public void init() {
new Timer().schedule(new TimerTask() {
@Override
public void run() {
JSObject.getWindow(AppletName.this).call("show", new Object[] {});
}
}, 500); // Delay by 500ms
}
```
4. **Security Settings in Firefox**:
Modern versions of Firefox have deprecated or restricted certain features related to applets due to security concerns. Ensure that your applet is signed and trusted by the browser. Additionally, check if the `about:config` settings in Firefox allow Java applets to run.
5. **Alternative Approaches**:
If the issue persists, consider using modern web technologies such as HTML5 `` or WebGL instead of applets, as applets are largely obsolete and unsupported in most browsers today.
If none of these solutions work, further debugging may be required to identify specific differences in how Firefox handles applets compared to IE.