Home | All Questions | alt.html FAQ > Client-side Basic Scripting

How do I call a Java applet method, like repaint(); every couple of seconds from

Any public method in an applet can be called from JavaScript, as well as any public attribute can be accessed. This is called LiveConnect: http://www.galasoft-LB.ch/myjavascript/consulting/LiveConnect102

Since repaint() is a public method of your applet, you may call it from JavaScript. Let's say your applet is named "myApplet" (a very original name), use:

This will call the repaint method every 10 seconds:

<script type="text/javascript">
function repaintApplet()
{
  document.myApplet.repaint();
  setTimeout( "repaintApplet()", 10000 );
}

setTimeout( "repaintApplet()", 10000 );
</script>

Recommended Resources

Discussion

Related Questions