JavaScript 获取指定的cookie值
1、获取cookie的函数
function getCookie(cookieName) { var strCookie = document.cookie; var arrCookie = strCookie.split("; "); for(var i = 0; i < arrCookie.length; i++){ var arr = arrCookie[i].split("="); if(cookieName == arr[0]){ return arr[1]; } } return ""; }
2、调用
var user_id = getCookie("selected_prj_id");
推荐一个自己业余时间开发的网盘搜索引擎,360盘搜(www.360panso.com)