<!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>一款js 读取cookie 值代码</title>
<script>
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 decodeuricomponent(acrumb[1]);
}
// a cookie with the requested name does not exist
return null;
}
//读取cookie方法
getcookie('www.111cn.net');
</script>
</head>
<body>
</body>
</html>