日期:2014-05-18 浏览次数:20568 次
//写入COOKIE
var oTime=new Date();
var sValue="竹子"
document.cookie="userid="+sValue+";expires="+(oTime+9999);
//读取
//-----------------------
//偶直接COPY MSDN上的给你了,要打的话好长
function GetCookie(sName)
{
// cookies are separated by semicolons
var aCookie = document.cookie.split("; ");
for (var i=0; i < aCookie.length; i++)
{
// a name/value pair (a crumb) is separated by an equal sign
var aCrumb = aCookie[i].split("=");
if (sName == aCrumb[0])
return unescape(aCrumb[1]);
}
// a cookie with the requested name does not exist
return null;
}
------解决方案--------------------
那就用JS读JS写不就可以了。
不过也没有关系,他们是可以互相操作的。