<html>
<head>
<title>aa</title>
<script language="javascript">
var x,y,z,obj;
var down=false;
var i=10;
function init()
{
obj=event.srcElement;
obj.setCapture();
x=event.offsetX;
y=event.offsetY;
//z=obj.style.zIndex;
obj.style.zIndex=i++
down=true;
}
function divmove()
{
if(down)
{
with(obj.style)
{
posLeft=document.body.scrollLeft+event.x-x;
posTop=document.body.scrollLeft+event.y-y;
}
}
}
function divup()
{
//obj.style.zIndex=z;
down=false;
obj.releaseCapture();
}
function divadd()
{
var div=document.createElement("Div");
div.innerHTML="<div style='background-color:#eeeeee;position:absolute;left:30;top:30;height:70px;width:50px;border:solid 1px black' οnmοusedοwn='init()' οnmοusemοve='divmove()' οnmοuseup='divup()'>div2</div>";
var obj=document.getElementById("body1");
obj.appendChild(div);
}
</script>
</head>
<body id="body1">
<div style="background-color:#eeeeee;position:absolute;left:50;top:50;height:70px;width:50px;border:solid 1px black" οnmοusedοwn="init()" οnmοusemοve="divmove()" οnmοuseup="divup()">div1</div>
<div style="background-color:#eeeeee;position:absolute;left:70;top:70;height:70px;width:50px;border:solid 1px black" οnmοusedοwn="init()" οnmοusemοve="divmove()" οnmοuseup="divup()">div2</div>
<div style="background-color:#eeeeee;position:absolute;left:100;top:100;height:70px;width:50px;border:solid 1px black" οnmοusedοwn="init()" οnmοusemοve="divmove()" οnmοuseup="divup()">div3</div>
<input type="button" value="add" id="divadd" οnclick="divadd()">
</body>
</html>
<head>
<title>aa</title>
<script language="javascript">
var x,y,z,obj;
var down=false;
var i=10;
function init()
{
obj=event.srcElement;
obj.setCapture();
x=event.offsetX;
y=event.offsetY;
//z=obj.style.zIndex;
obj.style.zIndex=i++
down=true;
}
function divmove()
{
if(down)
{
with(obj.style)
{
posLeft=document.body.scrollLeft+event.x-x;
posTop=document.body.scrollLeft+event.y-y;
}
}
}
function divup()
{
//obj.style.zIndex=z;
down=false;
obj.releaseCapture();
}
function divadd()
{
var div=document.createElement("Div");
div.innerHTML="<div style='background-color:#eeeeee;position:absolute;left:30;top:30;height:70px;width:50px;border:solid 1px black' οnmοusedοwn='init()' οnmοusemοve='divmove()' οnmοuseup='divup()'>div2</div>";
var obj=document.getElementById("body1");
obj.appendChild(div);
}
</script>
</head>
<body id="body1">
<div style="background-color:#eeeeee;position:absolute;left:50;top:50;height:70px;width:50px;border:solid 1px black" οnmοusedοwn="init()" οnmοusemοve="divmove()" οnmοuseup="divup()">div1</div>
<div style="background-color:#eeeeee;position:absolute;left:70;top:70;height:70px;width:50px;border:solid 1px black" οnmοusedοwn="init()" οnmοusemοve="divmove()" οnmοuseup="divup()">div2</div>
<div style="background-color:#eeeeee;position:absolute;left:100;top:100;height:70px;width:50px;border:solid 1px black" οnmοusedοwn="init()" οnmοusemοve="divmove()" οnmοuseup="divup()">div3</div>
<input type="button" value="add" id="divadd" οnclick="divadd()">
</body>
</html>