JavaScript + DIV +CSS Implementation can drag message form

Source: Internet
Author: User
Css|javascript| can be dragged

<style>
#div {}{width:300px;height:200px;color=red;border-top:1px solid #000; border-bottom:1px solid #000; border-left:1px Solid #000; border-right:1px solid #000; size=13px;position:absolute;bottom:50px;right=80px;}

</style>

<body>
<script language= "JavaScript" >
var moveable = false;
Function AA (val)
{
var obj = document.getElementById ("div");
if (val = 0)
{
Obj.style.display= "";
var x,y;

x = Event.clientx;
y = event.clienty;

Obj.style.left=x;
Obj.style.top=y;
Alert ("X:" +x+ "Y:" +y);
}
Else
Obj.style.display= "None";
}
function Startgrap (obj)
{
if (event.button==1)
{
Obj.setcapture ();
Record mouse and layer position;
x0 = Event.clientx;
y0 = Event.clienty;
X1 = parseint (obj.style.left);
Y1 = parseint (obj.style.top);
moveable = true;
}
}
function Stopgrap (obj)
{
if (moveable)
{
Obj.releasecapture ()//to release the capture of the mouse
moveable = false;
}
}
function Grap (obj)
{
if (moveable)
{
Obj.style.left = x1 + event.clientx-x0;
Obj.style.top = y1 + event.clienty-y0;
}
}
</script>
<form id= "Form1" >
<input Type=button value= "div application" onmousemove= "AA (0);" >
<div id= "Div2" style= "background: #ff00cc; width=100px;" onmousemove= "AA (0);" > mouse move over to try </div>
<div id= "div" style= "display:none" onmousemove= "Grap" (this); " >
<div style= "border-top:1px solid red;position:absolute;right=1px;" ><span style= "Cursor:hand" ><font color= "#eee" ><b> shutdown </b></font></span>< /div>
<span>i like you, does you know? <br>if you don ' t know,now I tell you,i tell you!<br><br> transparent form, drag </span>
</div>
</form>

</body>



Related Article

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.