Hi,

The following html and javascript codes illustrate how a java applet can be dynamically loaded into a web page.
My question here is how can this be done purely with javavscript? i.e the div element is created and the applet inserted with the

appendChild method without having to use the link :-

AppletObject("TESTAPPLET","http://www.test.com/TESTAPPLET.jar","400","400","true");ao.write("appletDiv");'>Add Applet</a>


<html>
<head>
<style>
.one{
background-color:#FF0000;
width:400px;
height:400px;
float:left;
}
.two{
background-color:#00FF00;
width:400px;
height:400px;
float:left;
}
.three{
background-color:#0000FF;
width:400px;
height:400px;
float:left;
}
</style>
<script type="text/javascript" src="AppletObject.js"></script>
</head>
<body>
<div class="one"></div>
<div class="two" id="appletDiv"></div>
<div class="three"></div>
<a href='javascript:var ao = new

AppletObject("TESTAPPLET","http://www.test.com/TESTAPPLET.jar","400","400","true");ao.write("appletDiv");'>Add Applet</a>
</body>
</html>



/ Java Applet Object
function AppletObject(code, archive, width, height, mayscript){
this.code = code;
this.archive = archive;
this.library = "";
this.width = width;
this.height = height;
this.mayscript = mayscript;
this.write = function(div){
var d=document.getElementById(div);
var string = '<applet code="'+this.code+'" archive="'+this.archive+this.library+'" width="'+this.width+'" height="'+this.height+'"

mayscript="'+this.mayscript+'">';
for(var i = 0; i < this.param.length; i++){
string += '<param name="'+this.param[i].name+' value="'+this.param[i].value+'>';
}
string += this.alt;
string += '</applet>';
d.innerHTML = string;
};
this.addParam = function(name, value){
var appletParam = new Object();
appletParam.name = name;
appletParam.value = value;
this.param.push(appletParam);
};
this.addLibrary = function(file){
if(file.charAt(0) == ',' || this.library.charAt(this.library.length-1) == ','){
library += file;
} else {
library += ',' + file;
}
}
this.folder = this.archive.substring(0, this.archive.lastIndexOf("/")) + "/";
this.alt = 'To view this content, you need to install Java from <A HREF="http://java.com">java.com</A>';
this.param = new Array();
}


Thanks.