There is nothing to say about this. Essence Put the code directly! Intersection
The first is the code of HTML. It contains the login click button and a humble login box.
Copy code code as follows:
<body>
<div ID = "shade"> </div>
<div>
<a OnClick = "Login ()" STYLE = "Cursor: Pointer"> Login </a>
</div>
<br/>
Nothing is useful. Essence Essence <br/> <br/>
Nothing is useful. Essence Essence <br/> <br/>
Nothing is useful. Essence Essence <br/> <br/>
Nothing is useful. Essence Essence <br/> <br/>
<br/> <br/> <br/> <br/> <br/> <br/> <br/> <br/> <br/> <br/> <br/> <br/> <br/> <br/> <br/> <br/> <br/> <br/> <br/> <br/> <br/>
<br/> <br/> <br/> <br/> <br/> <br/> <br/> <br/> <br/> <br/> <br/> <br/> <br/> <br/> <br/> <br/> <br/> <br/> <br/> <br/> <br/>
<div ID = "login" style = "display: none; z-index: 1025; posity: absolute;">
<FORM METHOD = "Post" Action = "User/Login.html">
<Table>
<CAPTION>
User login
</caption>
<tr>
<TD> Username: </td>
<td> <input type = "text" name = "username" /> < /td>
</tr>
<tr>
<TD> Password: </td>
<td> <input type = "password" name = "password" /> < /td>
</tr>
<tr>
<TD> Verification Code: </td>
<td> <img src = "base/verfy.html" onClick = ""> </td>
</tr>
<tr>
<td> <input type = "submit" value = "login" /> < /td>
<td> <input type = "Button" value = "Cancel" OnClick = "Cancel ()" /> < /td>
</tr>
</table>
</form>
</div>
</body>
Next is the implementation of the JS script code
Copy code code as follows:
<script type = "text/javascript">
Function login () {) {
var Shadewidth = Document.body.clientWidth + 30;
var Shadeheight = Document.body.Clientheight + 30;
var shade = document.GetelementByid ("shade");
shade.style.width = shadewidth + "px";
shade.style.head = shadeheight + "px";
shade.style.display = "block";
var logIDIVWIDTH = 200;
var logIDIVHEIGHT = 800;
var logIDIV = document.GetelementByid ("Login");
logindiv.style.width = logindivwidth + "px";
Logindiv.style.height = logindivheight + "px";
Logindiv.style.top = (Document.body.scrolltop + Document.body.clitingheight / 2
-Logindivheight / 2) + "px";
Logindiv.style.left = (Document.body.ScrollLeft + Document.body.clientWidth / 2
-LogindivWidth / 2) + "PX";
logindiv.style.display = "block";
}
</script>
Here are only the code display and the code of the login box. As for the hidden code, it is also very simple, that is, setting the DIV block of the Shade layer and the Display property of the DIV block of the login box (Login) should be set to None. There should be no problem. Essence
At this point, a simple function of the floating layer DIV login through the mask layer is implemented. The work of art is solved by everyone.
Here, there is a feature for everyone. Essence How to let the dIV block of the pop -up login box follow the rolling bar? Intersection
My experiment code is as follows.
Copy code code as follows:
Function Logindivcenter () {
Logindiv.style.top = (Document.body.scrolltop + Document.body.clitingheight / 2
-Logindivheight / 2) + "px";
Logindiv.style.left = (Document.body.ScrollLeft + Document.body.clientWidth / 2
-LogindivWidth / 2) + "PX";
}
function scall () {) {
Logindivcenter ();
}
window.onscroll = scall;
window.onresize = scall;
window.onload = scall;
But unfortunately I failed. Essence I found a lot on the Internet, but none of them met the requirements. Most of them set a setInterval to implement. I don't think this is ideal. Essence Essence
Seeking to teach all the great gods!