Use javascript to move the div layer-javascript drag layer:
Program function: Use javascript development to drag the div layer in the following html code at Will on the interface.
Javascript mobile div layer-javascript drag Layer Code-
Html code:
Copy codeThe Code is as follows:
<Div id = "div_Info" style = "display: none; dz-index: 101; left: 175px; width: pixel PX;
Position: absolute; top: pixel; "align =" center ">
<Table border = "0" cellpadding = "0" cellspacing = "0">
<Tr>
<% -- The following td adds the javascript code moving layer, dragging several events of the layer
Onmousedown event occurs when you click the mouse
The onmousemove event occurs when the mouse pointer moves.
The onmouseup event occurs when the mouse button is released,
Onmouseout event occurs when the mouse pointer is removed from the specified object -- %>
<Td style = "width: 628px; height: 22px; background-color: #3f3200;" class = "div_table_bian"
Onmousedown = "movetianyamessage (div_Info, event)" onmousemove = "movetianyamessageend (event );"
Onmouseup = "movetianyamessageend (event)" onmouseout = "movetianyamessageend (event)">
</Td>
<Td style = "width: 22px; background-color: #221B00; font-size: 12px; color: # ffffff;
Height: 22px; "align =" center "class =" div_table_notLeft_bian ">
<A href = "javascript: disponseNone (div_Info)" style = "color: White;"> x </a> </td>
</Tr>
<Tr>
<Td colspan = "2" style = "background-color: #000000" align = "center" valign = "top" class = "div_table_notTop_bian">
<Table border = "0" cellpadding = "0" cellspacing = "0" style = "width: 90%">
<Tr>
<Td style = "height: 25px;"> </td>
</Tr>
<Tr>
<Td style = "height: 23px;" class = "white12px" align = "center">
<Asp: Label ID = "div_lblTitle" runat = "server" Font-Size = "16px"> </asp: Label> </td> </tr>
<Tr> <td style = "height: 15px" valign = "top"> </td> </tr>
<Tr> <td id = "Div_Td_Content" runat = "server" class = "white12px" valign = "top"> </td> </tr>
<Tr> <td runat = "server" class = "white12px" valign = "top" style = "height: 15px"> </td> </tr>
<Tr> <td class = "white12px" style = "height: 40px" align = "center" valign = "middle">
<Asp: ImageButton ID = "ImageButton2" runat = "server" ImageUrl = "~ /Images/returns.jpg"
OnClientClick = "disponse_div (div_Info); return false;"/> </td> </tr>
</Table>
</Td> </tr>
</Table>
</Div>
Javascript mobile div layer-javascript drag Layer code-javascript code:Copy codeThe Code is as follows: <script language = "javascript">
// Javascript file
/* Call Method
// Onmousedown = "movetianyamessage (div_Info, event)" onmousemove = "movetianyamessageend (event );"
// Onmouseup = "movetianyamessageend (event)" onmouseout = "movetianyamessageend (event )"
// Onmousedown = when the mouse clicks, onmousemove = when the mouse passes, onmouseup = when the mouse is up, onmouseout = when the mouse leaves
*/
Var tianyamessage =''
Var ilayermaxnum= 999;
Document. onmouseup = movetianyamessageend;
Document. onmousemove = movetianyamessagestart;
Var tianyamessagepixefX;
Var tianyamessagepixefY;
Function movetianyamessage (Object, event)
{
Tianyamessage = Object. id;
If (document. all)
{
Document. getElementById (tianyamessage). setCapture ();
TianyamessagepixefX = event. x-document. getElementById (tianyamessage). style. pixelLeft;
TianyamessagepixefY = event. y-document. getElementById (tianyamessage). style. pixelTop;
}
Else if (window. captureEvents)
{
Window. captureEvents (Event. MOUSEMOVE | Event. MOUSEUP );
TianyamessagepixefX = event. layerX;
TianyamessagepixefY = event. layerY;
}
Document. getElementById (tianyamessage). style. zIndex = iLayerMaxNum;
ILayerMaxNum = iLayerMaxNum + 1;
}
Function movetianyamessagestart (evt)
{
If (tianyamessage! = ''){
If (document. all)
{
Document. getElementById (tianyamessage). style. left = event. x-tianyamessagepixefX;
Document. getElementById (tianyamessage). style. top = event. y-tianyamessagepixefY;
}
Else if (window. captureEvents)
{
Document. getElementById (tianyamessage). style. left = (evt. clientX-tianyamessagepixefX) + "px ";
Document. getElementById (tianyamessage). style. top = (evt. clientY-tianyamessagepixefY) + "px ";
}
}
}
Function movetianyamessageend (evt)
{
If (tianyamessage! = '')
{
If (document. all)
{
Document. getElementById (tianyamessage). releaseCapture ();
Tianyamessage = '';
}
Else if (window. captureEvents ){
Window. captureEvents (Event. MOUSEMOVE | Event. MOUSEUP );
Tianyamessage = '';
}
}
}
Function disponse_div (obj)
{
If (obj. style. display = "block ")
{
Obj. style. display = "none ";
}
Else
{
Obj. style. display = "block ";
}
}
</Script>