这是我的asp代码,可以在Javascript中完成吗?
HttpCookie cookie = this.Request.Cookies["Votes"]; if (cookie != null) if (cookie.Values.Get(id.ToString()) == "true") return true; return false;
解决方法
function readTheCookie(the_info) { // load the cookie into a variable and unescape it var the_cookie = document.cookie; var the_cookie = unescape(the_cookie); // separate the values from the cookie name var broken_cookie = the_cookie.split("some parameter"); // parameter depends on how the cookie is stored var the_values = broken_cookie["some index"]; // index of the value that you want }
这些都是阅读cookie的所有部分,您可以使用此片段来实现您想要的效果.