Layer dragging Effect

Source: Internet
Author: User
<! Doctype HTML public "-// W3C // dtd xhtml 1.0 transitional // en" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<HTML xmlns = "http://www.w3.org/1999/xhtml" lang = "gb2312">
<Head>
<Title> code example: drag the drag object (compatible with IE, Firefox, and opera). </title>
<Meta http-equiv = "Content-Type" content = "text/html; charset = gb2312"/>
<! -- <Meta name = "Editor" content = "fengyan, http://www.cnlei.com">
<Meta name = "keywords" content = "code instance: drag an object">
<Meta name = "Description" content = "brief example of dragging object code"> -->
<Style>
. Dragable {} {position: relative; cursor: move ;}
</Style>
<Script language = "JavaScript">
<! --
// Author: unkonw
// Modify: fengyan @ cnlei.com
VaR Ie = Document. All;
VaR nn6 = Document. getelementbyid &&! Document. All;
VaR isdrag = false;
Var y, X;
VaR odragobj;
Function movemouse (e ){
If (isdrag ){
Odragobj. style. Top = (nn6? Nty + E. clienty-Y: nty + event. clienty-y) + "PX ";
Odragobj. style. Left = (nn6? NTX + E. clientx-X: NTX + event. clientx-x) + "PX ";
Return false;
}
}
Function initdrag (e ){
VaR odraghandle = nn6? E.tar get: event. srcelement;
VaR topelement = "html ";
While (odraghandle. tagname! = Topelement & odraghandle. classname! = "Dragable "){
Odraghandle = nn6? Odraghandle. parentnode: odraghandle. parentelement;
}
If (odraghandle. classname = "dragable "){
Isdrag = true;
Odragobj = odraghandle;
Nty = parseint (odragobj. style. Top + 0 );
Y = nn6? E. clienty: event. clienty;
NTX = parseint (odragobj. style. Left + 0 );
X = nn6? E. clientx: event. clientx;
Document. onmousemove = movemouse;
Return false;
}
}
Document. onmousedown = initdrag;
Document. onmouseup = new function ("isdrag = false ");
// -->
</SCRIPT>
</Head>
<Body>


<br/>
<Div style = "border: 1px solid # ff6d00; Background: # ffd801; width: 240px; padding: 5px 0; "Class =" dragable "> these are all drag objects </div>
</Body>
</Html>

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.