弹出一个登录层,并对登录进行校验

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="弹出层.aspx.cs" Inherits="弹出层" %>

<!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>
    <!-- 这里一段JS的代码,主要是两个方法。一个是隐藏层。一个是打开层 -->

    <script language="javascript" type="text/javascript">
    
      function ShowDiv(){
     var Show = document.getElementById("login");
     Show.style.position = "absolute";
     Show.style.visibility = "visible";
     Show.style.display = "block";
}
function ClosDiv(){
var Clos = document.getElementById("login");
Clos.style.visibility = "hidden";
Clos.style.display = "none";
}
function LoginIn()
{
alert('a');
 var username=document.getElementById("username");
 var password=document.getElementById("passwodr");
 alert(username.value);
 alert(password.value);
 if(username.value=="admin"&&password.value=="admin")
 {
     window.location.href("Default.aspx");
 }
}
    </script>

</head>
<body>
    <a href="#" onclick="ShowDiv()">登录</a> <a href="#" onclick="ClosDiv()">取消</a>
    <div id="login" style="visibility: hidden; display: none; border: 1px #CCCCCC solid;
        width: 300px;">
        <div style="width: 300px; height: 20px; background-color: #CCCCFF; display: block">
            <div style="width: 5px; height: 5px; margin-left: 140px; margin-top: 5px;">
                <input type="submit" value="X" onclick="ClosDiv()" width="2px;" height="2px;" />
            </div>
        </div>
        <div>
            <form action="">
                用户名:<input type="text" id="username" /><br />
                密 码:
                <input id="passwodr" type="password" /><br />
                <input id="btnlogin" type="button" value="登录" onclick="LoginIn()" />&nbsp;&nbsp;&nbsp;
                <input type="reset" value="清空" />
                <input type="button" value="关闭" onclick="ClosDiv()" />
            </form>
        </div>
    </div>
</body>
</html>

posted @ 2012-04-12 17:09  王永华  阅读(150)  评论(0编辑  收藏  举报