js原生Cookie(健康项目获取设置获取百度地图Cookie信息)

原生js获取Cookie

function getCookie(name){

var strcookie = document.cookie;//获取cookie字符串

var arrcookie = strcookie.split("; ");//分割

//遍历匹配

for ( var i = 0; i < arrcookie.length; i++) {

var arr = arrcookie[i].split("=");

    if (arr[0] == name){

         return arr[1];

    }

}

        return "";

}

你可能感兴趣的:(js原生Cookie(健康项目获取设置获取百度地图Cookie信息))