日期:2014-05-16  浏览次数:21027 次

关于登陆时用户名存入CooKie不起作用,请教帮看一下错误,谢谢!
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>网站登陆</title>
<script type="text/javascript">
function SaveCookie()
{
  var data=escape(document.getElementById("username").value);

  var d=new Date();
  d.setDate(d.getDate()+1);//1天内有效
  document.cookie="data="+data+";expires="+d.toGMTString();
}
function ReadCookie()
{
  var d="";
  var match=document.cookie.match(/data=([^;]+);?/i);
  if(match)
  {
    d=match[1];
    document.getElementById("username").value=unescape(d);
   }
}
window.onload=ReadCookie;
window.onunload=SaveCookie;
</script>

<script>
function test(){
document.getElementById("addBtn").onclick = openme();
}
</script>
</head>
<body onLoad="test()">
<style type="text/css">
body {
margin: 0px;padding:0
}
#div1 {
display: none;
position: absolute;
z-index: 1000;
height: 100%;
width: 100%;
background: #000000;
filter:Alpha(opacity=30);
}
#div2 {
display: none;
position: absolute;
height: 100%;
width: 100%;
padding-top: 10%;
z-index: 1001;
left: 0px;
top: 0px;
}
</style>
<script>
function openme(){
document.getElementById('div1').style.display='block';
document.getElementById('div2').style.display='block';
}
function closeme(){
document.getElementById('div1').style.display='none';
document.getElementById('div2').style.display='none';
}
function logo_in(){alert()
//验证
//转向...
//myform.action=""
//login.submit()
closeme();
}
</script>
<script language="javascript">
    function  KeyDown()
    {
    if(event.keyCode==13)
    {
    document.login.submit();
    }
    }
</script>
<div id="div1"></div>
<div id="div2">
<table width="20%" border="0" cellpadding="0" cellspacing="1" style="background: #0043cf; position:static;filter:progid:DXImageTransform.Microsoft.DropShadow(color=#CCCCCC,offX=4,offY=4,positives=true)" align="center">
<tr id="m_tr">
<td height="33" background="images/Main_Line.gif"><table width="100%" height="33" border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td><font color="#0043cf">&nbsp;<strong>欢迎登陆:</strong></font></td>
    <td width="33"><input align="absMiddle" id="image2" name="image2" src="images/close_0.png" type="image" WIDTH="27" HEIGHT="27" onClick="closeme()" style="cursor: hand;"></td>
  </tr>
</table></td>
</tr>
<tr>
<form name="login"  method="post" action="index.asp">
<td width="100%" height="150" colspan="2" valign="top" bgcolor="#F