<div class="codetitle"> <span><a style="CURSOR: pointer" data="35863" class="copybut" id="copybut35863" onclick="doCopy('code35863')"><u>複製程式碼</u></a></span> 程式碼如下:</div> <div class="codebody" id="code35863"> <br> <br><br><br> <title></title> <br> <script type="text/lt;script type="text/lt; javascript"><br> function showLogin() {<br> var loginDiv = docum o = document.getElementById("zhezhao");<br> var clientx = document .documentElement .clientWidth;<br> var clienty = document.documentElement.clientHeight;<br> 🎜> var t_margin = (clienty - parseInt(loginDiv.style ) .height)-200) / 2<br> loginDiv.style.left = l_margin "px";<br> loginDiv.style .display = "block"; <br> zhezhao.style.display = "block";<br> }<br> var loginDiv = document.getElementById("loginDiv");<br> var zhezhao = document.getElementById ( } zhezhao");<br> loginDiv.style.display = "none";<br> > function titleMove() { <br> var move能夠=真實; <br> var loginDiv = document.getElementById("loginDiv");<br> var clientX = window.event.clientX;<br> var clientY = window. event.clientY;<br> var moveTop = parseInt(loginDiv.style.top);<br> document.onmousemove = function MouseMove() {<br> 若(可移動) {<br> var y = moveTop window.event.clientY - clientY; if (x > 0 &&& y > 0) {<br> loginDiv.style.top = y "px"; }<br> 🎜> document.onmouseup = function Mouseup() {<br> 可動= false;<br> <br> <br><br><br><!--主起始 z-index:0--><br><div id="Main" style="position:absolute;z-index:0;"> <br><a href="javascript:showLogin()">登陸</a><br> </div> <br><!--主開始z -index:0--><br><!--loginDiv start :z-index:2--><br><div id="loginDiv" style="background-color:white;width:300px;height : 150px;邊框:1px 純藍色;z-index:2;顯示:無;位置:絕對;border-top:無"> <br> <br> <!--<img src="../images/ close. jpg" style="max-width:90%" onclick="hidLogin()"/ alt="利用js實作遮罩以及彈出可移動登入視窗_javascript技巧" >--><br> <a href="javascript:hidLogin()" style="float:right;text-decoration:none;顏色:白色;邊距右:2px;字體大小:20px">×</a><br> <br> <table style="clear:right;width:298px;height:115px; text=" clear:right text-align :right> <br> <tr> <td> ;使用者名稱:</td> <td><input type="text" style="width:180px;"></td> <td> </td> </tr> <br> <tr> <td>密碼:</td> <td><input type="text" style="width:180px;"></td> <td> </td> </tr> <br> <tr> <td><br></td> <td></td> </tr> <br> <br> <br><br><!--loginDiv end :z-index:2--><br><!--zhezhao start:z-index:1--> <br><div id="zhezhao" style="position:absolute;z-index:1;寬度:100%;高度:100%;背景顏色:銀色;顯示:無;不透明度:.5 ;"> <br><!--折結束--><br> </div> <br><br><br><br>【效果】<a href="http://images.cnitblog.com/blog/539789/201307/05192043-3594e818cdfe428a9fa12ccce867e9da.png"><img style="max-width:90%" title="image" border="0" alt="image" src="http://files.jb51.net/file_images/article/201307/201307080928172.png" style="max-width:90%" style="max-width:90%"></a> </table> </div> </div>