Set Applet PARAM VALUE from javascriptTag(s): Javascript interaction


PARAM VALUE can't be changed ar run-time but during layout time, javascript "entities" can be used to set calculated VALUES.

In this How-to, VALUES are coming from a javascript variable, a javascript function and a javascript expression.

<HTML><HEAD></HEAD><BODY>
<SCRIPT>
var jsVar = "Hello World from jsVar";

function jsFnct() {
  return "Hello World from jsFnct";
  }
  
</SCRIPT></HEAD><BODY>
<<APPLET CODE ="MyApplet.class" HEIGHT=100 WIDTH=400>
  <PARAM NAME="first"  VALUE="&{jsVar};">
  <param name="second" value="&{jsFnct()};">
  <param name="third" 
    value="&{'hello world'.toUpperCase() + ' from js Expression'};">
</APPLET>
</BODY></HTML>

For demonstration purpose, the MyApplet class

import java.applet.*;    
import java.awt.*;    

public class MyApplet extends Applet  {

 public void init() {
  add(new Label(getParameter("first")));
  add(new Label(getParameter("second")));
  add(new Label(getParameter("third")));
  }
}
NOTE: Javascript entities are not supported in IE. The workaround is to use the document.write() method to customize the APPLET PARAM during layout time. See this How-to for an example.
blog comments powered by Disqus