Java applet code can't be called from a Javascript function if this function is called by onLoad event

RESOLVED FIXED

Status

RESOLVED FIXED
15 years ago
9 years ago

People

(Reporter: lorenzomiopalmo, Unassigned)

Tracking

Trunk
x86
Linux

Firefox Tracking Flags

(Not tracked)

Details

(Reporter)

Description

15 years ago
User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.6) Gecko/20040113
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.6) Gecko/20040113

Java applet code can't be called from a Javascript function if this function is
called by onLoad event.
This does not happen if the applet is run on a Click-buttun event.


Reproducible: Always
Steps to Reproduce:
a sample Java applet contains only an init() method and another method called
setString(), who draw a text "Hello World" in a box.
When HTML page loading, a Javascript function call the Java method setString().


Actual Results:  
JavaScript error: appletBase.setString() is not a function. The Java method is
not invoked.

Expected Results:  
the text "Hello World" appears.
(Reporter)

Comment 1

15 years ago
see java code:
import java.applet.Applet;
import java.awt.Graphics;

public class HelloWorld extends Applet {   String myString;

   public void init() {
         myString = new String("Init");
            }   
            
   public void paint(Graphics g) {
         g.drawString(myString, 25, 20);
            }
   public void setString(String aString) {      myString = aString;        
repaint();   }
  }


see HTML+javascript:

<html>
  <head>
<SCRIPT>
<!--- Hide script from old browsers

  function getAppletBase() {
	    var appletBase;
	    appletBase = document.applets[0];
	    return appletBase;
  }

  function loadPage(pre) {
    var appletBase = getAppletBase();
    if(appletBase) {
  	       if (pre) appletBase.setString(pre);
  	       else appletBase.setString(" Hello World");
    }
  }

// end hiding from old browsers -->
</SCRIPT>
  <body onLoad="loadPage()">
<APPLET CODE="HelloWorld.class" NAME="Hello" WIDTH=150 HEIGHT=25>
</APPLET>
<FORM NAME="form1">
<INPUT TYPE="button" VALUE="onClick"  
onClick="loadPage(document.form1.id.value);"><BR>
<input type="hidden" name="id" value="C'est encore bon ?"></FORM>
</CENTER>
</body>
</html>

Updated

15 years ago
Assignee: general → live-connect
Component: Browser-General → Java: Live Connect
QA Contact: general → pschwartau

Comment 2

15 years ago
I forgot to add that it happened 3 times since I installed Java 1.5.0 and
_never_ before installing it. Previously I had Java 1.4.2_05

Comment 3

15 years ago
Ignore comment #2. Wrong bug!!!
(Reporter)

Comment 4

15 years ago
All is OK with a plug-in Java 1.5.0 !!!
(Reporter)

Updated

15 years ago
Status: UNCONFIRMED → RESOLVED
Last Resolved: 15 years ago
Resolution: --- → FIXED

Updated

9 years ago
Component: Java: Live Connect → Java: Live Connect
Product: Core → Core Graveyard
You need to log in before you can comment on or make changes to this bug.