码迷,mamicode.com
首页 > Web开发 > 详细

JS获取Cookie

时间:2015-11-27 12:53:20      阅读:149      评论:0      收藏:0      [点我收藏+]

标签:

function getCookie(name) {
  var offset, cookieValue;
  var search = name + "=";
  if (document.cookie.length > 0) {
    offset = document.cookie.indexOf(search);
    if (offset != -1) {
    offset += search.length;
    end = document.cookie.indexOf(";", offset);
    if (end == -1)
    end = document.cookie.length;
    cookieValue = unescape(document.cookie.substring(offset, end));
    }
  }
  return cookieValue;
}

JS获取Cookie

标签:

原文地址:http://www.cnblogs.com/autocephaly/p/5000093.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!