<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>无标题文档</title>
</head>
<body>
<script>
function getCookieValue(cookieName)
{
var cookieValue = document.cookie;
var cookieStartAt = cookieValue.indexOf(" " + cookieName + "="); 
    if(cookieStartAt == -1)
{
cookieStartAt = cookieValue.indexOf(cookieName + "="); 
}
if(cookieStartAt == -1)
{
cookieValue == null; 
}
else 
{
    cookieSatrtAt = cookieValue.indexOf("=", cookieStartAt)+1;
    cookieEndsAt = cookieValue.indexOf(";", cookieStartAt);
if(cookieEndsAt == -1)
{
    cookieEndsAt == cookieValue.length;
}
cookieValue = unescape(cookieValue.substring(cookieStartAt,cookieEndsAt));
}
return cookieValue;
}
document.cookie ="name=Bob;age=20";
document.write(getCookieValue("age"));
</script>
</body>
</html>
htmljavascriptcookiefunction