Drag the transparent Div with the mouse

Source: Internet
Author: User

 
<HTML>
<Head>
<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;
Cursor: hand;
}

</Style>
</Head>

<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 the 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 (); // used to release Mouse capture
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: green; width = 50px;" onmousemove = "AA (0);"> move the cursor over and try again </div>
<Div id = "Div" style = "display: none; left: 0px; bottom: 50px;" onmousedown = "startgrap (this);" onmouseup = "stopgrap (this ); "onmousemove =" GRAP (this); ">
<Div style = "border-top: 1px solid red; position: absolute; Right = 1px;"> <span onclick = "AA (1);" style = "cursor: hand "> <font color =" # Eee "> <B> disable </B> </font> </span> </div>
For a long time without your trust for a long time no one will talk with me miss your tender and watery eyes it's the most beautiful stars in the sky, Midnight is particularly deserted a man and a eager letter do not know the distance can you sense it? ----- revengeboy
<Br/>
<Span> <br>
& Nbsp; transparent form that can be dragged </span>
<Br/>
Test !!! </Div>
</Form>

</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.