jquery implements pop-up removable layer code

Source: Internet
Author: User

Iframe.html page

<meta http-equiv= "Content-type" content= "text/html; Charset=utf-8 "/>
<title> Pop-up window display </title>
<body>
<div id= "Container" style= "Overflow:hidden;" >
<iframe border= "0" id= "content" src= "demo1.html" frameborder= "0" height= "100%" width= "100%" ></iframe>
</div>
</body>

Pop up the moveable Layer page, and part of jquery judgment

<meta http-equiv= "Content-type" content= "text/html; Charset=utf-8 "/>
<title>login</title>
<link rel= "stylesheet" href= "Logindialog.css" type= "Text/css"/>
<script type= "Text/javascript" src= ". /js/jquery-1.8.3.js "></script>
<body>
<a href= "#" id= "example" > Login DIY Account window example </a>
<div id= "Loginbox" >
<div class= "Row1" >
Login DIY Account window <a href= "javascript:void (0)" title= "Close Window" class= "close_btn" id= "closebtn" >x</a>
</div>
<div class= "Row" >
User name: <span class= "InputBox" >
<input type= "text" id= "txtname" placeholder= "account/Mailbox"/>
</span><a href= "javascript:void (0)" title= "hint" class= "warning" id= "warn" >*</a>
</div>
<div class= "Row" >
Secret &nbsp;&nbsp;&nbsp;&nbsp; code: <span class= "InputBox" >
<input type= "text" id= "txtpwd" placeholder= "password"/>
</span><a href= "javascript:void (0)" title= "hint" class= "warning" id= "warn2" >*</a>
</div>
<div class= "Row" >
<a href= "#" id= "loginbtn" > Login </a>
</div>
</div>
<script type= "Text/javascript" >
$ (function ($) {
Popup Login
$ ("#example"). Hover (function () {
$ (this). Stop (). Animate ({
Opacity: ' 1 '
}, 600);
}, function () {
$ (this). Stop (). Animate ({
Opacity: ' 0.6 '
}, 1000);
})

$ ("#example"). Click (function () {
$ ("Body"). Append ("<div id= ' mask ' ></div>");
$ ("#mask"). AddClass ("Mask"). FadeIn ("slow");
$ ("#LoginBox"). FadeIn ("slow");
});
//
Transparency of buttons
$ ("#loginbtn"). Hover (function () {
$ (this). Stop (). Animate ({
Opacity: ' 1 '
}, 600);
}, function () {
$ (this). Stop (). Animate ({
Opacity: ' 0.8 '
}, 1000);
});
text box is not allowed to be empty---button trigger
$ ("#loginbtn"). Click (function () {
var txtname = $ ("#txtName"). Val ();
var txtpwd = $ ("#txtPwd"). Val ();
if (txtname = = "" | | Txtname = = Undefined | | Txtname = = null) {
if (txtpwd = = "" | | Txtpwd = = Undefined | | Txtpwd = = null) {
$ (". Warning"). CSS ({display: ' block '});
}
else {
$ ("#warn"). CSS ({display: ' block '});
$ ("#warn2"). CSS ({display: ' None '});
}
}
else {
if (txtpwd = = "" | | Txtpwd = = Undefined | | Txtpwd = = null) {
$ ("#warn"). CSS ({display: ' None '});
$ (". Warn2"). CSS ({display: ' block '});
}
else {
$ (". Warning"). CSS ({display: ' None '});
}
}
});

});
</script>

<script type= "Text/javascript" >
$ (document). Ready (function () {
$ ("#txtName"). focus (function () {
$ ("#warn"). CSS ({display: ' None '});
});

$ ("#txtPwd"). focus (function () {
$ ("#warn2"). CSS ({display: ' None '});
});

Shut down
$ (". Close_btn"). Hover (function () {$ (this). CSS ({color: ' Black '})}, function () {$ (this). CSS ({color: ' #999 '})}). CLI CK (function () {
$ ("#LoginBox"). FadeOut ("fast");
$ ("#mask"). CSS ({display: ' None '});
});

$ ("#loginbtn"). On ("click", Function () {
var checkname = false;
var Checkpass=false;
var Textname,textpass;
Textname = $ ("#txtName"). Val ();
Textpass = $ ("#txtPwd"). Val ();
text box is not allowed to be empty---single text trigger
var txtname = $ ("#txtName"). Val ();
if (txtname = = "" | | Txtname = = Undefined | | Txtname = = null) {
$ ("#warn"). CSS ({display: ' block '});
}
else {
$ ("#warn"). CSS ({display: ' None '});
Checkname=true;
}
Password
var txtname = $ ("#txtPwd"). Val ();
if (txtname = = "" | | Txtname = = Undefined | | Txtname = = null) {
$ ("#warn2"). CSS ({display: ' block '});
}
else {
$ ("#warn2"). CSS ({display: ' None '});
Checkpass = true;
}

if (CheckName = = = False) {
Alert (' Please enter user name ');
Return
}
if (Checkpass = = = False) {
Alert (' Please enter password ');
Return
}

if (Checkname===true & Checkpass ===true) {
$.post ("checklogin.php", {' txtname ': textname, ' txtpwd ': textpass},function (data) {
alert (data);
});
}
});


$ (' #LoginBox '). MouseMove (function (event) {
var ismove = true;
var abs_x = Event.pagex-$ (' #LoginBox '). Offset (). Left;
var abs_y = event.pagey-$ (' #LoginBox '). Offset (). Top;
$ (document). MouseMove (function (event) {
if (ismove) {
var obj = $ (' #LoginBox ');
Obj.css ({' Left ': event.pagex-abs_x, ' top ': event.pagey-abs_y});
}
}). Click (function () {
Ismove = false;
});
});

});


</script>

</body>

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.