Similar to the blog Drag module code

Source: Internet
Author: User
<title> Mobile Window </title>
<style>
*{FONT-SIZE:12PX}
. dragtable{
font-size:12px;
border-top:1px solid #3366cc;
margin-bottom:10px;
width:100%;
Background-color: #FFFFFF;
}
. dragtr{
Cursor:move;
Color: #7787cc;
Background-color: #e5eef9;
}
Td{vertical-align:top;}
#parentTable {
Border-collapse:collapse;
letter-spacing:25px;
}
</style>

<script defer>
var Draged=false;
Tdiv=null;
function DragStart () {
Ao=event.srcelement;
if ((ao.tagname== "TD") | | (ao.tagname== "TR")) Ao=ao.offsetparent;
else return;
Draged=true;
Tdiv=document.createelement ("div");
tdiv.innerhtml=ao.outerhtml;
tdiv.style.display= "Block";
tdiv.style.position= "Absolute";
Tdiv.style.filter= "Alpha (opacity=70)";
Tdiv.style.cursor= "Move";
Tdiv.style.width=ao.offsetwidth;
Tdiv.style.height=ao.offsetheight;
Tdiv.style.top=getinfo (AO). Top;
Tdiv.style.left=getinfo (AO). Left;
Document.body.appendChild (TDIV);
Lastx=event.clientx;
Lasty=event.clienty;
Lastleft=tdiv.style.left;
Lasttop=tdiv.style.top;
try{
Ao.dragdrop ();
}catch (e) {}
}
function draging () {//IMPORTANT: Determine the location of the mouse
if (!draged) return;
var Tx=event.clientx;
var Ty=event.clienty;
Tdiv.style.left=parseint (lastleft) +tx-lastx;
Tdiv.style.top=parseint (lasttop) +ty-lasty;
for (Var i=0;i<parenttable.cells.length;i++) {
var parentcell=getinfo (Parenttable.cells[i]);
if (tx>=parentcell.left&&tx<=parentcell.right&&ty>=parentcell.top&&ty<= Parentcell.bottom) {
var subtables=parenttable.cells[i].getelementsbytagname ("table");
if (subtables.length==0) {
if (tx>=parentcell.left&&tx<=parentcell.right&&ty>=parentcell.top&&ty<= Parentcell.bottom) {
Parenttable.cells[i].appendchild (AO);
}
Break
}
for (Var j=0;j<subtables.length;j++) {
var subtable=getinfo (Subtables[j]);
if (tx>=subtable.left&&tx<=subtable.right&&ty>=subtable.top&&ty<= Subtable.bottom) {
Parenttable.cells[i].insertbefore (Ao,subtables[j]);
Break
}else{
Parenttable.cells[i].appendchild (AO);
}
}
}
}
}

function Dragend () {
if (!draged) return;
Draged=false;
MM=FF (150,15);
}
function GetInfo (o) {//Get coordinates
var to=new Object ();
to.left=to.right=to.top=to.bottom=0;
var twidth=o.offsetwidth;
var theight=o.offsetheight;
while (O!=document.body) {
To.left+=o.offsetleft;
To.top+=o.offsettop;
O=o.offsetparent;
}
To.right=to.left+twidth;
To.bottom=to.top+theight;
return to;
}
function ff (AA,AB) {//From Google Web site to restore location
var ac=parseint (GetInfo (Tdiv). left);
var ad=parseint (GetInfo (tdiv). top);
var ae= (Ac-getinfo (AO). left)/ab;
var af= (Ad-getinfo (AO). top)/ab;
Return SetInterval (function () {if (ab<1) {
Clearinterval (mm);
Tdiv.removenode (TRUE);
Ao=null;
Return
}
ab--;
Ac-=ae;
AD-=AF;
Tdiv.style.left=parseint (AC) + "px";
Tdiv.style.top=parseint (AD) + "px"
}
, Aa/ab)
}
function Inint () {//initialization
for (Var i=0;i<parenttable.cells.length;i++) {
var subtables=parenttable.cells[i].getelementsbytagname ("table");
for (Var j=0;j<subtables.length;j++) {
if (subtables[j].classname!= "dragtable") break;
Subtables[j].rows[0].classname= "DRAGTR";
Subtables[j].rows[0].attachevent ("onmousedown", DragStart);
Subtables[j].attachevent ("Ondrag", draging);
Subtables[j].attachevent ("Ondragend", dragend);
}
}
}
Inint ();

</script>
<body>
<table border= "0" cellpadding= "0" cellspacing= "ten" width= "100%" height=500 id= "ParentTable" >
<tr >
&LT;TD width= "25%" valgin= "Top" >
<table border=0 class= "dragtable" cellspacing= "0" >
<tr>
<td>AJAX</td>
</tr>
<tr>
&LT;TD id= "Div4" ></td>
<tr>
</table>
<table border=0 class= "dragtable" cellspacing= "0" >
<tr>
<td>datagrid</td>
</tr>
<tr>
&LT;TD id= "DIV5" ></td>
<tr>
</table>
<table border=0 class= "dragtable" cellspacing= "0" >
<tr>
<td>asp.net</td>
</tr>
<tr>
&LT;TD id= "Div3" ></td>
<tr>
</table></td>
&LT;TD width= "25%" >
<table border=0 class= "dragtable" cellspacing= "0" >
<tr>
<td>C#.net</td>
</tr>
<tr>
&LT;TD id= "Div2" > </td>
<tr>
</table></td>
&LT;TD width= "25%" >
<table border=0 class= "dragtable" cellspacing= "0" id= "TD3" >
<tr>
&LT;TD >javascrip<a href= "#" onclick= "document.all.td3.style.display= ' None" "onmousedown=" document.all.imag1.src= ' icon2.gif ' "onmouseup=" document.all.imag1.src= ' icon.gif ' "onfocus=" This.blur () ">< IMG src= "icon.gif" width= "height=" id= "Imag1" border= "0" ></a></td>
</tr>
<tr>
&LT;TD id= "DV" ><div id= "DIV10" ></div></td>
<tr>
</table>
</td>
</tr>
</table>
</body>
-->

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.