首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > JavaScript >

这个代码 具体是什么意思!解决思路

2013-04-05 
这个代码 具体是什么意思!本帖最后由 yulelcom 于 2013-03-27 22:56:21 编辑functionsingplay() {var self

这个代码 具体是什么意思!
本帖最后由 yulelcom 于 2013-03-27 22:56:21 编辑

function  singplay() {
    var self = this;
    this.prefix = "sing_play__fm_";
    this.playIndex = -1;
    this.listIndex = { PlayList: 0, MusicBox: 1 };
    this.isLogin = false;
    this.countMusicbox = -1;
    this.cookieList = { PlayList: this.prefix + "0", MusicBox: this.prefix + "1" };
    this.cookie;
    this.agent;
    this.init();
}

singplay.prototype.init = function () {
    var self = this;
    this.cookie = self.cookieList.PlayList;
};

singplay.prototype.setCurrentCookie  =   function  (o) {
  this.cookie = o;
};


其他页面的
查找数组中是否包含某个元素

*/
Array.prototype.include = function (val) {
    return this.index(val) !== null;
}
//#endregion

//#region getCookie
/*获取cookie
*/
function getCookie(name) {
    var arr = document.cookie.match(new RegExp("(^| )" + name + "=([^;]*)(;|$)"));
    if (arr != null) return JSON.parse(unescape(arr[2])); return null;
}
function getcookie(name)//取cookies函数        
{
    var arr = document.cookie.match(new RegExp("(^| )" + name + "=([^;]*)(;|$)"));
    if (arr != null) return unescape(arr[2]); return null;

}
//#endregion

//#region setCookie
/*设置cookie
*/
function setCookie(name, value) {
    var Days = 30; //此 cookie 将被保存 30 天

    var exp = new Date();    //new Date("December 31, 9998");
    exp.setTime(exp.getTime() + Days * 24 * 60 * 60 * 1000);
    document.cookie = name + "=" + escape(value) + ";expires=" + exp.toGMTString();
    //alert(getCookie(name) + "||" + name);
}
//#endregion

//#region deleteCookie
/*删除cookie
*/
function deleteCookie(name, path, domain) {
    if (getcookie(name)) {
        document.cookie = name + '=' +
            ((path) ? ';path=' + path : '') +
            ((domain) ? ';domain=' + domain : '') +
            ';expires=Thu, 01-Jan-1970 00:00:01 GMT';
    }
}



这个代码 具体是什么意思!   上面代码  访问一个页面后   在访问其他新的页面  久的页面!  之前的页面会内容被覆盖!输出的    cookie  最新访问的   数据



怎么改成不 覆盖   

用PHP 或者的话  要怎么写

javascript function
[解决办法]
粗粗看过去你还没找到关键的代码。搜一下 singplay
[解决办法]
嗯,搜一下 setCookie
[解决办法]
你没发出关键的代码,找一代码里那个部分调用了 setCookie
[解决办法]
不是说两个文件吗?还有一个文件在那?也有可能没有调用setCookie,你给的代码只是实现没有调用。
再试试查找addToPlaylist,saveData,估计在saveData里。

热点排行