QQ浏览器设置cookie不成功是怎么回事?

//关闭提示条

var CookieUtil={

    get:function(name){

        var cookieName=encodeURIComponent(name)+"=",

            cookieStart=document.cookie.indexOf(cookieName),

            cookieValue=null;

        if(cookieStart>-1){

            var cookieEnd=document.cookie.indexOf(";",cookieStart);

            if(cookieEnd==-1){

                cookieEnd=document.cookie.length;

            }

            cookieValue=decodeURIComponent(document.cookie.substring(cookieStart+cookieName.length,cookieEnd));

        }

        return cookieValue;

    }

};


var clo=document.getElementById("close");

var tst=document.getElementById("tishitiao");

EventUtil.addHandler(clo,"click",function(){

    tst.style.display="none";

    document.cookie=encodeURIComponent("closetst")+"="+encodeURIComponent("closetst");

});

setTimeout(function(){

    var cookie=CookieUtil.get("closetst"); //通过这些代码设置的cookie,ie8及火狐能正常读取,但是qq浏览器不知为什么读取不了,总是为null,这是为啥?

    if(cookie){

    tst.style.display="none";

    }

},0);


米琪卡哇伊
浏览 449回答 1
1回答

慕姐4208626

我建议使用jq的插件jquery.cookie.js
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

JavaScript