function getCookie(objName)//獲取指定名稱的cookIE的值
...{
var arrStr = document.cookIE.split(";");
for(var i = 0;i < arrStr.length;i++)
...{
var temp = arrStr[i].split("=");
if(objName.trim()==temp[0].trim()) //此處如果沒有去掉字符串空格就不行,偶在這裡折騰了半死,主要是這種錯誤不好跟蹤啊
...{
return temp[1];
}
}
}
function setCookie()//設置cookIE
...{
if((document.getElementById ('TextBox1').value!="")&&(document.getElementById ('TextBox2').value!=""))
...{
document.cookIE ="userName="+document.getElementById ('TextBox1').value;
document.cookIE ="passWord="+document.getElementById ('TextBox2').value;
}
}
</script>
</head>
<body onload =rememberUser()>
<form id="form1" runat="server">
<div>
<asp:TextBox ID="TextBox1" runat="server" Width="120px" EnableVIEwState="False"></ASP:TextBox>
<br />
<br />
<asp:TextBox ID="TextBox2" runat="server" Width="120px" EnableVIEwState="False"></ASP:TextBox><br />
<br />
<ASP:Button ID="Button1" runat="server" Text="Button" OnClientClick="setCookIE()"/></div>
</form>
</body>
</Html>