日期:2014-05-18  浏览次数:20692 次

JAVASCRIPT 无法读取COOKIE
高手帮我看看这两个页面是一起使用的第一个页面没什么问题第二个页面无法读取

写入的HTML(写入的页面非有问题)
<!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>
<meta   http-equiv= "Content-Type "   content= "text/html;   charset=gb2312 "   />
<title> 生成COOKIE </title>
<script   type= "text/javascript ">
<!--
function   writeCooke()
{
var   d   =   new   Date();
d.setTime(d.getTime()   +   24*60*60);
var   cookiestr   =   escape(document.getElementById( "mF ").name.value   +   "? "   +   document.getElementById( "mF ").sex.value   +   "? "   +   document.getElementById( "mF ").age.value   +   "? "   + document.getElementById( "mF ").prow.value   +   "? "   +   document.getElementById( "mF ").Email.value);
document.cookie   =   "UserInfo   =   "+cookiestr+ ";expires= "+d.toGMTString();
window.location   =   "显示Cookie.html ";
}
//-->
</script>
</head>

<body>
<form   id= "mF ">
<table   border= "0 ">
<tr>
<td>
姓名: <input   id= "name "   type= "text "   size= "15px "   />
</td>
</tr>
<tr>
<td>
性别: <input   id= "sex "   type= "text "   size= "15px "   />
</td>
</tr>
<tr>
<td>
年龄: <input   id= "age "   size= "15px "   />
</td>
</tr>
<tr>
<td>
省份:
<select   id= "prow ">
<option   value= "吉林 "> 吉林 </option>
<option   value= "北京 "> 北京 </option>
<option   value= "山东 "> 山东 </option>
<option   value= "上海 "> 上海 </option>
<option   value= "陕西 "> 陕西 </option>
<option   value= "河北 "> 河北 </option>
<option   value= "广西 "> 广西 </option>
</select>
</td>
</tr>
<tr>
<td>
E-mail: <input   type= "text "   size= "25px "   id= "Email "   />
</td>
</tr>
<tr   align= "center ">
<td>
<input   type= "button "   onclick= "writeCooke(); "   value= "完成 "   />
</td>
</tr>
</table>
</form>
</body>
</html>


读取的HTML页面(读取的页面无法正常读取)
var   cookiestr   =   document.cookie;
var   start   =   0;end   =   0;
if(cookiestr.indexOf( "UserInfo= ")   !=   -1)
{
start   =   cookiestr.indexOf( "UserInfo= ")   +   "UserInfo ".length;
e