Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

onLoad attribute for Applet tag doesn't work??

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
Hi All
I'm trying to test the onLoad Event Handler that what i assume we can use with applet tag or Object tag.as :
<object code=&quot;TextFieldApplet10.class&quot; id=&quot;matt&quot; width=&quot;500&quot; height=&quot;200&quot; onLoad=&quot;show();&quot; >
</object>
just simply i need to click on the applet and get what ever response fro show() method.
I used it with the input tag for button and it works,but with applet tag it doesn't work for some reason.
Here is the java and html files.
//======= TextFieldApplet10.java=====
import java.awt.*;
import java.awt.event.*;
import java.applet.*;
public class TextFieldApplet10 extends Applet
{
public void init()
{
TextField txt1 = new TextField(&quot; &quot;);
add(txt1);
txt1.addActionListener(new moh());
this.setBackground(Color.red);
}
}
class moh implements ActionListener
{
public void actionPerformed(ActionEvent e)
{
System.out.println(&quot;Hello&quot;);

}
}
//======testApplet.html =====
<script language=&quot;javascript&quot; >
function show()
{
var y=88;
document.writeln(&quot;hello world today &quot;);
return y;

}
</script>

<html>
<body>
<form action=&quot;&quot; >

<object code=&quot;TextFieldApplet10.class&quot; id=&quot;matt&quot; width=&quot;500&quot; height=&quot;200&quot; onLoad=&quot;show();&quot; >
</object>
<input type=&quot;button&quot; value=&quot;Click on me &quot; onClick=&quot;show();&quot;></a>

</form>
</body>
</html>

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top