javascript不是很难,但添加控件的事件如onclick等,要用attachEvent('onclick',调用的函数),不过这只是IE的写法,其它的写法以后再做



<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>JS test</title>
</head>

<body>
<input type="button" name="Button1" value="创建DIV" onClick="createDiv()">
</body>
</html>
<script language="javascript">
<!--
 function createDiv(){
 var div1 = document.createElement("DIV");
 div1.id = "div1";
 div1.style.position="absolute";
 div1.style.top=40;
 div1.style.left=0;
 div1.style.width='644px';
 div1.style.height='229px';
 div1.style.background = "#FFFF00";
 div1.style.visibility = "visible";
 div1.innerHTML="";
 document.body.removeChild(this.document.getElementById("Button1"));
 document.body.appendChild(div1);
 
 createLabel(div1,30,5,"颜色");
 createInput("text","DivCorlor",30,30,div1);
 createBR(div1);
 
 createLabel(div1,50,5,"透明度");
 createInput("text","DivTM",50,30,div1);
 createBR(div1);
 
 createLabel(div1,70,5,"大小:");
 createLabel(div1,70,9,"宽度");
 createInput("text","DivWidth",70,15,div1);
 createLabel(div1,70,39,"高度");
 createInput("text","DivHeight",70,43,div1);
 createBR(div1);
 

 
 createLabel(div1,90,5,"位置:");
 createLabel(div1,90,9,"top");
 createInput("text","DivTop",90,15,div1);
 createLabel(div1,90,39,"left");
 createInput("text","DivLeft",90,43,div1);
 createBR(div1);
 

 
 createButton(110,30,div1);
 

 
 
 }
 
 function createLabel(appendObj,topObj,leftObj,textObj)
 {
  var label1= document.createElement("Label");
 label1.style.position="relative";
 label1.style.top=topObj;
 label1.style.left=leftObj;
 label1.innerHTML=textObj;
 appendObj.appendChild(label1);
 }
 
 function createInput(typeObj,nameObj,topObj,leftObj,appendObj)
 {
 var input1 = document.createElement("INPUT");
 input1.type=typeObj;
 input1.name=nameObj;
 input1.id=nameObj;
 input1.size="20";
 input1.style.position="relative";
 input1.style.top=topObj;
 input1.style.left=leftObj;
 appendObj.appendChild(input1);
 
 }
 
 function createBR(appendObj)
 {
   var br1 = document.createElement("BR");
   appendObj.appendChild(br1);
 }
 
 function createButton(topObj,leftObj,appendObj)
 {
 var input1 = document.createElement("INPUT");
 input1.type="button";
 input1.name="Button1";
 input1.id="Button1";
 input1.style.position="relative";
 input1.style.top=topObj;
 input1.style.left=leftObj;
 input1.value="改变";
 input1.attachEvent('onclick', divChange);

 appendObj.appendChild(input1);

 }
 function test()
 {
  var obj=this.document.getElementById("Button1");
  alert(obj);
  alert(obj.onClick);
 }
 function divChange()
 {
   var divObj=this.document.getElementById("div1");
   divObj.style.width=this.document.getElementById("DivWidth").value;
   divObj.style.height=this.document.getElementById("DivHeight").value;
   divObj.style.top=this.document.getElementById("DivTop").value;
   divObj.style.left=this.document.getElementById("DivLeft").value;
   divObj.style.background=this.document.getElementById("DivCorlor").value;
   divObj.style.filter='alpha(opacity:'+this.document.getElementById("DivTM").value+')';
 }
//-->
</script>