深海的小鱼儿

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::

现在我们需要一个简单的帐号和密码来控制我们的web入口地址,我们的开发环境是javascript下面是我们的代码

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>无标题文档</title>
<script language="JavaScript" type="text/javascript">
function sc()
{
    alert("xmphoenix!");
}

function check()
{
    var name=document.getElementById("user").value;
    var Passwd=document.getElementById("passwd").value;
    if(name=="xmphoenix"&&Passwd=="xmphoenix")
    {
        alert("登录成功!");
        window.location.href="index.html"
    }
    else
    {
        alert("没有此帐号!或者密码错误!");
    }
}

</script>
<style type="text/css">
<!--
#Layer1 {
    position:absolute;
    width:378px;
    height:184px;
    z-index:1;
    left: 282px;
    top: 57px;
}
-->
</style>
</head>

<body>
<div id="Layer1">
  <form name="form1" method="post" action="">
    name : 
      <input name="user" type="text" id="user">
  </form>
  <form name="form2" method="post" action="">
    passwd
    <input name="passwd" type="password" id="passwd">
  </form>
  <p>
   <input name="Submit" type="button" onDblClick="javascript:check()
" value="提交">
  </p>
</div>
</body>
</html>

带有紫色的地方就是关键的代码,只要理解了就很简单~

1  ok n

posted on 2011-03-19 16:58  深海的小鱼儿  阅读(860)  评论(0编辑  收藏  举报