1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 2 <html xmlns="http://www.w3.org/1999/xhtml"> 3 4 <head> 5 <title> 6 </title> 7 <script type="text/javascript"> 8 function showLogin() { 9 var loginDiv = document.getElementById("loginDiv"); 10 var zhezhao = document.getElementById("zhezhao"); 11 var clientx = document.documentElement.clientWidth; 12 var clienty = document.documentElement.clientHeight; 13 var l_margin = (clientx - parseInt(loginDiv.style.width)) / 2; 14 var t_margin = (clienty - parseInt(loginDiv.style.height) - 200) / 2 loginDiv.style.left = l_margin + "px"; 15 loginDiv.style.top = t_margin + "px"; 16 loginDiv.style.display = "block"; 17 zhezhao.style.display = "block"; 18 } 19 function hidLogin() { 20 var loginDiv = document.getElementById("loginDiv"); 21 var zhezhao = document.getElementById("zhezhao"); 22 loginDiv.style.display = "none"; 23 zhezhao.style.display = "none"; 24 } 25 function titleMove() { 26 var moveable = true; 27 var loginDiv = document.getElementById("loginDiv"); //以下变量提前设置好 var clientX = window.event.clientX; var clientY = window.event.clientY; var moveTop = parseInt(loginDiv.style.top); var moveLeft = parseInt(loginDiv.style.left); document.onmousemove = function MouseMove() { if (moveable) { var y = moveTop + window.event.clientY - clientY; var x = moveLeft + window.event.clientX - clientX; if (x > 0 && y > 0) { loginDiv.style.top = y + "px"; loginDiv.style.left = x + "px"; } } } document.onmouseup = function Mouseup() { moveable = false; } } 28 29 </script> 30 </head> 31 32 <body> 33 <!--Main start z-index:0--> 34 <div id="Main" style="position:absolute;z-index:0;"> 35 <a href="javascript:showLogin()"> 36 登陆 37 </a> 38 </div> 39 <!--Main start z-index:0--> 40 <!--loginDiv start :z-index:2--> 41 <div id="loginDiv" style="background-color:white;width:300px;height:150px;border:1px solid blue;z-index:2;display:none;position:absolute;border-top:none"> 42 <div onmousedown="titleMove()" id="login_title" style="width:300px;height:25px;background-color:Blue;border:1px solid silver;border-left:none;border-right:none"> 43 <!--<img src="../images/close.jpg" style="float:right" onclick="hidLogin()"/> 44 --> 45 <a href="javascript:hidLogin()" style="float:right;text-decoration:none;color:white;margin-right:2px;font-size:20px"> 46 × 47 </a> 48 </div> 49 <table style="clear:right;width:298px;height:115px;text-align:right;margin-top:10px;"> 50 <tr> 51 <td> 52 用户名: 53 </td> 54 <td> 55 <input type="text" style="width:180px;" /> 56 </td> 57 <td> 58 59 </td> 60 </tr> 61 <tr> 62 <td> 63 密码: 64 </td> 65 <td> 66 <input type="text" style="width:180px;" /> 67 </td> 68 <td> 69 70 </td> 71 </tr> 72 <tr> 73 <td> 74 <br /> 75 </td> 76 <td> 77 </td> 78 </tr> 79 </table> 80 </div> 81 <!--loginDiv end :z-index:2--> 82 <!--zhezhao start: z-index:1--> 83 <div id="zhezhao" style="position:absolute;z-index:1;width:100%;height:100%;background-color:silver;display:none;opacity:.5;"> 84 <!--zhezhao end--> 85 </div> 86 </body> 87 88 </html>