主要應用到的是dispaly:none 和 dispaly:block;來控制實作的;
<a id="link" href="#" onclick="linkonclick()">登入</a>這裡還有一種寫法
<a href="javascript:linkonclick()">登入</a>
兩種效果是一樣的;

View Code
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>點選超連結彈出層</title>
<style type="text/css">
*
{
margin: 0px;
padding: 0px;
}
body
background-image: url("../Images/Lv.gif");
font-size: 12px;
body a
font-size: 100px;
color: #FFF;
text-decoration: none;
.login
background: #FFF;
width: 560px;
height: 360px;
position: absolute;
top: 310px;
left: 510px;
padding: 10px;
z-index: 20;
display: none;
.login ul
list-style: none;
margin-left: 100px;
margin-top: 50px;
.clear
width: 600px;
height: 400px;
top: 300px;
left: 500px;
z-index: 10;
filter: alpha(opacity=40);
opacity: 0.4;
</style>
<script type="text/javascript" language="javascript">
function linkonclick() {
var divs = document.getElementsByTagName("div");
for (var i = 0; i < divs.length; i++) {
var newdiv = divs[i];
newdiv.style.display = "block";
}
function btnclick() {
newdiv.style.display = "none";
</script>
</head>
<body>
<a id="link" href="#" onclick="linkonclick()">登入</a>
<div class="login">
<ul>
<li>
<p>
使用者名:</p>
<input id="Text1" type="text" />
</li>
密&nbsp;&nbsp;碼:</p>
<input id="Text2" type="text" />
<input id="button" type="button" value="關閉" onclick="btnclick()" /></li>
</ul>
</div>
<div class="clear">
</body>
</html>