![]() |
#2
冰镇柠檬汁儿2015-04-24 12:06
|

function get_cookie(_name){
var Res=eval('/'+_name+'=([^;]+)/').exec(document.cookie); return Res==null?'':unescape(Res[1]);
};
var DomainUrl = "localhost";
function SetCookie(name, value){
var expdate = new Date();
var argv = SetCookie.arguments;
var argc = SetCookie.arguments.length;
var expires = (argc > 2) ? argv[2] : null;
var path = (argc > 3) ? argv[3] : null;
var domain = (argc > 4) ? argv[4] : null;
var secure = (argc > 5) ? argv[5] : false;
if(expires!=null) expdate.setTime(expdate.getTime() + ( expires * 1000 ));
document.cookie = name + "=" + escape (value) +((expires == null) ? "" : ("; expires="+ expdate.toGMTString()))+((path == null) ? "" : ("; path=" + path)) +((domain == null) ? "" : ("; domain=" + domain))+((secure == true) ? "; secure" : "");
};
function set_history(_url, _name, _id){
var current_str = _id + "#" + _name + "#" + _url + "*ylmv*";
var cookie_info = get_cookie("ylmvHistory");
var deal_cookie="";
if( "" != cookie_info){
cookie_info = cookie_info.split("*ylmv*");
var N = (cookie_info.length > 18) ? 18 : cookie_info.length - 1;
for(var i=0; i<N; i++){
if(current_str != cookie_info[i] + "*ylmv*" && '' != cookie_info[i]) deal_cookie += (cookie_info[i] + "*ylmv*");
}
}
current_str = ('' == deal_cookie) ? current_str : current_str + deal_cookie;
SetCookie("ylmvHistory", current_str, 48 * 3600, "/", DomainUrl, false);
};
function get_history(){
var cookie_info=get_cookie("ylmvHistory").split("*ylmv*");
var N = cookie_info.length - 1;
var history_list = "", infos, s;
for(var i=0; i<N; i++){
var ii = i+1;
infos = cookie_info[i].split("#");
history_list += '<li><span class="check"><input name="check" type="checkbox" value="'+infos[0]+'"></span> <span class="title"><a title="'+infos[1]+'" href="'+infos[2]+'" target="_self">'+infos[1]+'</a></span></li>';
}
$A("music_list").innerHTML = history_list;
$A("list_do").innerHTML = '<a href="javascript:void(0)" onclick="del_history();return false;" class="his">清除记录</a>';
};
function del_history(){
SetCookie("ylmvHistory", "", null, "/", DomainUrl, false);
$A("music_list").innerHTML = "<li class='selected'> 清除试听记录成功!</li>";
};
function over_bg(t){ t.style.background = '#FFFFFF'; };
function out_bg(t){ t.style.background = '#FFFFFF'; };
set_history(location.href, music_name ,music_id);
var Res=eval('/'+_name+'=([^;]+)/').exec(document.cookie); return Res==null?'':unescape(Res[1]);
};
var DomainUrl = "localhost";
function SetCookie(name, value){
var expdate = new Date();
var argv = SetCookie.arguments;
var argc = SetCookie.arguments.length;
var expires = (argc > 2) ? argv[2] : null;
var path = (argc > 3) ? argv[3] : null;
var domain = (argc > 4) ? argv[4] : null;
var secure = (argc > 5) ? argv[5] : false;
if(expires!=null) expdate.setTime(expdate.getTime() + ( expires * 1000 ));
document.cookie = name + "=" + escape (value) +((expires == null) ? "" : ("; expires="+ expdate.toGMTString()))+((path == null) ? "" : ("; path=" + path)) +((domain == null) ? "" : ("; domain=" + domain))+((secure == true) ? "; secure" : "");
};
function set_history(_url, _name, _id){
var current_str = _id + "#" + _name + "#" + _url + "*ylmv*";
var cookie_info = get_cookie("ylmvHistory");
var deal_cookie="";
if( "" != cookie_info){
cookie_info = cookie_info.split("*ylmv*");
var N = (cookie_info.length > 18) ? 18 : cookie_info.length - 1;
for(var i=0; i<N; i++){
if(current_str != cookie_info[i] + "*ylmv*" && '' != cookie_info[i]) deal_cookie += (cookie_info[i] + "*ylmv*");
}
}
current_str = ('' == deal_cookie) ? current_str : current_str + deal_cookie;
SetCookie("ylmvHistory", current_str, 48 * 3600, "/", DomainUrl, false);
};
function get_history(){
var cookie_info=get_cookie("ylmvHistory").split("*ylmv*");
var N = cookie_info.length - 1;
var history_list = "", infos, s;
for(var i=0; i<N; i++){
var ii = i+1;
infos = cookie_info[i].split("#");
history_list += '<li><span class="check"><input name="check" type="checkbox" value="'+infos[0]+'"></span> <span class="title"><a title="'+infos[1]+'" href="'+infos[2]+'" target="_self">'+infos[1]+'</a></span></li>';
}
$A("music_list").innerHTML = history_list;
$A("list_do").innerHTML = '<a href="javascript:void(0)" onclick="del_history();return false;" class="his">清除记录</a>';
};
function del_history(){
SetCookie("ylmvHistory", "", null, "/", DomainUrl, false);
$A("music_list").innerHTML = "<li class='selected'> 清除试听记录成功!</li>";
};
function over_bg(t){ t.style.background = '#FFFFFF'; };
function out_bg(t){ t.style.background = '#FFFFFF'; };
set_history(location.href, music_name ,music_id);
前台页面
<script type="text/javascript">var music_classid = "2";var music_id = "2";var music_name = "我是标题";</script>
读取不了cookie,求大神看看