Dynamic insertion of applet

  • Thread starter Tormod Omholt-Jensen
  • Start date
T

Tormod Omholt-Jensen

I need to dynamically insert the following applet code in my document:


<OBJECT classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93" WIDTH = 0
HEIGHT = 0 NAME = "myApplet"
codebase="http://java.sun.com/products/plugin/autodl/jinstall-1_3_1_03-win.cab#Version=1,3,1,3">
<PARAM NAME = CODE VALUE = "FooApplet.class" >
<PARAM NAME = CODEBASE VALUE = "http://foo.com/java/" >
<PARAM NAME = ARCHIVE VALUE = foo.jar" >
<PARAM NAME = NAME VALUE = "fooApplet" >
<PARAM NAME = MAYSCRIPT VALUE = true >
<PARAM NAME = "type" VALUE =
"application/x-java-applet;jpi-version=1.3.1_03">
<PARAM NAME = "scriptable" VALUE = "true">

<COMMENT>
</COMMENT>
</OBJECT>


The code above works fine in IE6/XP. For dyn. insertion, I try the
code below, but it does not load the applet properly. Any ideas?


<SCRIPT language="JavaScript">

var obj = document.createElement("object");
obj.setAttribute("classid", "clsid:8AD9C840-044E-11D1-B3E9-00805F499D93");
obj.setAttribute("width", "0");
obj.setAttribute("height", "0");
obj.setAttribute("name", "myApplet");
obj.setAttribute("id", "myApplet");
obj.setAttribute("codebase",
"http://java.sun.com/products/plugin/autodl/jinstall-1_3_1_03-win.cab#Version=1,3,1,3");

var p1 = document.createElement("param");
p1.setAttribute("name", "code");
p1.setAttribute("value", "FooApplet.class");
obj.appendChild(p1);

var p2 = document.createElement("param");
p2.setAttribute("name", "codebase");
p2.setAttribute("value", "http://foo.com/java/");
obj.appendChild(p2);

var p3 = document.createElement("param");
p3.setAttribute("name", "archive");
p3.setAttribute("value", "foo.jar");
obj.appendChild(p3);

var p4 = document.createElement("param");
p4.setAttribute("name", "name");
p4.setAttribute("value", "fooApplet");
obj.appendChild(p4);

var p5 = document.createElement("param");
p5.setAttribute("name", "mayscript");
p4.setAttribute("value", "true");
obj.appendChild(p5);

var p6 = document.createElement("param");
p6.setAttribute("name", "scriptable");
p4.setAttribute("value", "true");
obj.appendChild(p6);

var p7 = document.createElement("param");
p7.setAttribute("name", "type");
p4.setAttribute("value",
"application/x-java-applet;jpi-version=1.3.1_03");
obj.appendChild(p7);

document.body.appendChild(obj);

</SCRIPT>
 
W

W d'Anjos

Try to use simple document.writeln's as follows:

<SCRIPT language=JavaScript>
document.writeln('<OBJECT classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93"');
document.writeln('WIDTH = 0 HEIGHT = 0 NAME = "myApplet"');
document.writeln(...
document.writeln('</OBJECT>');
</SCRIPT>

I hope this helps.

Wagner
 
T

Tormod Omholt-Jensen

Thanks for the suggestion. This works if the script is run before the
onload event is trigged. I need however to insert the applet _after_ the
onload event. Using document.write at this stage clears all the already
displayed content of the browser.

Tormod


On Thu, 2 Oct 2003, W d'Anjos wrote:

|Try to use simple document.writeln's as follows:
|
|<SCRIPT language=JavaScript>
|document.writeln('<OBJECT classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93"');
|document.writeln('WIDTH = 0 HEIGHT = 0 NAME = "myApplet"');
|document.writeln(...
|document.writeln('</OBJECT>');
|</SCRIPT>
|
|I hope this helps.
|
|Wagner
|
|> I need to dynamically insert the following applet code in my document:
|>
|>
|> <OBJECT classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93" WIDTH = 0
|> HEIGHT = 0 NAME = "myApplet"
|> codebase="http://java.sun.com/products/plugin/autodl/jinstall-1_3_1_03-win.cab#Version=1,3,1,3">
|> <PARAM NAME = CODE VALUE = "FooApplet.class" >
|> <PARAM NAME = CODEBASE VALUE = "http://foo.com/java/" >
|> <PARAM NAME = ARCHIVE VALUE = foo.jar" >
|> <PARAM NAME = NAME VALUE = "fooApplet" >
|> <PARAM NAME = MAYSCRIPT VALUE = true >
|> <PARAM NAME = "type" VALUE =
|> "application/x-java-applet;jpi-version=1.3.1_03">
|> <PARAM NAME = "scriptable" VALUE = "true">
|>
|> <COMMENT>
|> </COMMENT>
|> </OBJECT>
|>
|>
|> The code above works fine in IE6/XP. For dyn. insertion, I try the
|> code below, but it does not load the applet properly. Any ideas?
|>
|>
|> <SCRIPT language="JavaScript">
|>
|> var obj = document.createElement("object");
|> obj.setAttribute("classid", "clsid:8AD9C840-044E-11D1-B3E9-00805F499D93");
|> obj.setAttribute("width", "0");
|> obj.setAttribute("height", "0");
|> obj.setAttribute("name", "myApplet");
|> obj.setAttribute("id", "myApplet");
|> obj.setAttribute("codebase",
|> "http://java.sun.com/products/plugin/autodl/jinstall-1_3_1_03-win.cab#Version=1,3,1,3");
|>
|> var p1 = document.createElement("param");
|> p1.setAttribute("name", "code");
|> p1.setAttribute("value", "FooApplet.class");
|> obj.appendChild(p1);
|>
|> var p2 = document.createElement("param");
|> p2.setAttribute("name", "codebase");
|> p2.setAttribute("value", "http://foo.com/java/");
|> obj.appendChild(p2);
|>
|> var p3 = document.createElement("param");
|> p3.setAttribute("name", "archive");
|> p3.setAttribute("value", "foo.jar");
|> obj.appendChild(p3);
|>
|> var p4 = document.createElement("param");
|> p4.setAttribute("name", "name");
|> p4.setAttribute("value", "fooApplet");
|> obj.appendChild(p4);
|>
|> var p5 = document.createElement("param");
|> p5.setAttribute("name", "mayscript");
|> p4.setAttribute("value", "true");
|> obj.appendChild(p5);
|>
|> var p6 = document.createElement("param");
|> p6.setAttribute("name", "scriptable");
|> p4.setAttribute("value", "true");
|> obj.appendChild(p6);
|>
|> var p7 = document.createElement("param");
|> p7.setAttribute("name", "type");
|> p4.setAttribute("value",
|> "application/x-java-applet;jpi-version=1.3.1_03");
|> obj.appendChild(p7);
|>
|> document.body.appendChild(obj);
|>
|> </SCRIPT>
|
 
L

Lasse Reichstein Nielsen

Tormod Omholt-Jensen said:
Using document.write at this stage clears all the already displayed
content of the browser.

Yep.
Please trim your quotes instead of including the enitre message you
reply to (and it doesn't help that the one you reply to did the same).

Anyway:
|> var p5 = document.createElement("param");
|> p5.setAttribute("name", "mayscript");
|> p4.setAttribute("value", "true");

Shouldn't this be two times "p5.setAttribut". Ditto for the two next
params.
/L
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,535
Members
45,007
Latest member
OrderFitnessKetoCapsules

Latest Threads

Top