如题,我在一个链接的点击事件中设置了cookie值,但是在页面跳转后的page.load()事件中读取的时候经常是旧的值,就是当页面加载的时候,我设置的cookie值还没有生效,有什么办法没?

解决方案 »

  1.   

    写cookie后读出来,看看对不对,不对则检查写cookie页面
    对则可能是读cookie页面有缓存
      

  2.   

    代码呢,如何设置的?<a href="xxxx.aspx" onclick="document.cookie='abc=abc;path=/'">xxx</a>这样?如果是这样xxx.aspx获取到的abc cookie值应该是最新的
      

  3.   


    $(document).ready(function(){

    if(getCookie() != null){
    var indexValue = getCookie();
    alert(indexValue)
    $(".rightnavlist li ul").hide();
    $(".rightnavlist").children("li:eq("+indexValue+")").find(".text").show();//如果cookies存在,则输出cookIe
    }

    })点击链接的时候响应setCookie函数,我在setCookie函数里弹出COOKIE也是正常的,但是在$(document).ready中弹出的却是旧的值//获取Cookie
    function getCookie(){
    var indexValue = $.cookie("navid");
    return indexValue;
    }//存入Cookie
    function setCookie(indexValue){
    $.cookie("navid",indexValue);
    return true;
    }
      

  4.   


    多谢大侠的回答:真的只要在设置的cookie后面加上path=/ 就可以使每次js都会去取最新的document.cookie了!