Js+css implement a Drag pop-up prompt box _javascript tips

Source: Internet
Author: User

The example in this article describes the JS+CSS implementation can be dragged pop-up balloon. Share to everyone for your reference. The implementation methods are as follows:

Copy Code code as follows:
<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
<meta http-equiv= "Content-type" content= "text/html; Charset=utf-8 "/>
&LT;TITLE&GT;JS+CSS-Drag pop-up tip box </title>
<style type= "Text/css" >
a{color: #000; Font-size:12px;text-decoration:none}
a:hover{color: #900; Text-decoration:underline}
Body{background:;filter:progid:dximagetransform.microsoft.gradient (gradienttype=0,startcolorstr= #ffffff, Endcolorstr= #003366); Overflow:hidden}
#massage_box {position:absolute left:expression (body.clientwidth-350)/2); Top:expression (body.clientheight-200 )/2); width:350px; Height:200px;filter:dropshadow (color= #666666, offx=3,offy=3,positive=2); Z-index:2; Visibility:hidden}
#mask {position:absolute; top:0; left:0; width:expression (body.scrollwidth); height:expression (body.scrollHeight); Background: #666; Filter:alpha (opacity=60); Z-index:1; Visibility:hidden}
Massage{border: #036 solid; border-width:1 1 3 1; width:95%; height:95%; background: #fff; color: #036; font-size:12px; Lin e-height:150%}
Header{background: #036; height:10% Font-family:verdana, Arial, Helvetica, Sans-serif; font-size:12px; padding:3 5 0 5; Color: #fff}
</style>
<!--realize Layer moving-->
<script language= "JavaScript" >
var obj= '
Document.onmouseup=mup
Document.onmousemove=mmove
function Mdown (Object) {
Obj=object.id
document.all (OBJ). SetCapture ()
Px=event.x-document.all (OBJ). Style.pixelleft;
Py=event.y-document.all (OBJ). Style.pixeltop;
}

function Mmove () {
if (obj!= ') {
document.all (OBJ). style.left=event.x-px;
document.all (OBJ). Style.top=event.y-py;
}
}

function MUp () {
if (obj!= ') {
document.all (OBJ). ReleaseCapture ();
Obj= ';
}
}
</script>
<div id= "Massage_box" ><div class= "Massage" >
<div class= "Header" Onmousedown=mdown (Massage_box) >
<span onclick= "massage_box.style.visibility= ' hidden"; mask.style.visibility= ' hidden ' "style=" float:right; Display:inline; Cursor:hand ">x</span></div>
</div></div>
<div id= "Mask" ></div>
<span onclick= ' mask.style.visibility= ' visible ' massage_box.style.visibility= ' visible ' style= ' Cursor:hand ' ><a href= "#" ><font size=18px> dot this hint </font></a></span>
</body>

I hope this article will help you with your JavaScript programming.

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.