By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,607 Members | 1,978 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,607 IT Pros & Developers. It's quick & easy.

Dynamic insertion of applet

P: n/a

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>

Jul 20 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
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

Tormod Omholt-Jensen <to*@pvv.org> wrote in message news:<Pi*******************************@verden.pvv .ntnu.no>...
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>

Jul 20 '05 #2

P: n/a

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
|
|Tormod Omholt-Jensen <to*@pvv.org> wrote in message news:<Pi*******************************@verden.pvv .ntnu.no>...
|> 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>
|
Jul 20 '05 #3

P: n/a
Tormod Omholt-Jensen <to*@pvv.org> writes:
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
--
Lasse Reichstein Nielsen - lr*@hotpop.com
Art D'HTML: <URL:http://www.infimum.dk/HTML/randomArtSplit.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 20 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.