How can I dynamically set an applet's param values using JavaScript?
Created May 4, 2012
Use document.write to generate the APPLET and enclosing PARAM tags.
In the example, the parameter names and values are static, but they could for instance be fetched from cookies.
NOTE: Don't bother trying to generate only the PARAM tags (and leave the APPLET tag as regular HTML) because it won't work.
<HTML>
<HEAD>
<SCRIPT LANGUAGE="JavaScript">
function writeAppletTag() {
document.writeln('<APPLET CODE="MyApplet" WIDTH="100" HEIGHT="100">');
document.writeln(buildParamTag('name1','value1'));
document.writeln(buildParamTag('name2','value2'));
document.writeln('</APPLET>');
}
function buildParamTag(name, value) {
return '<PARAM NAME="' + name + '" VALUE="' + value + '">';
}
</SCRIPT>
</HEAD>
<BODY>
<SCRIPT LANGUAGE="JavaScript">
writeAppletTag();
</SCRIPT>
</BODY>
</HTML>