function set_cookie(name, value, expirehours, domain) 
{
	var today = new Date();
	today.setTime(today.getTime() + (60*60*1000*expirehours));
	document.cookie = name + "=" + escape( value ) + "; path=/; expires=" + today.toGMTString() + ";";
}
function mlink1() {location.href = "/sub03/01.php";	set_cookie("sub", 1, 365);}
function mlink2() {location.href = "/sub03/01.php";	set_cookie("sub", 2, 365);}
function mlink3() {location.href = "/sub03/01.php";	set_cookie("sub", 3, 365);}
function mlink4() {location.href = "/sub03/01.php";	set_cookie("sub", 4, 365);}

function get_cookie(name) {
	var find_sw = false;
	var start, end;
	var i = 0;
	for (i=0; i<= document.cookie.length; i++)
	{
		start = i;
		end = start + name.length;
		if(document.cookie.substring(start, end) == name) 
		{
			find_sw = true
			break
		}
	}
	if (find_sw == true) 
	{
		start = end + 1;
		end = document.cookie.indexOf(";", start);
		if(end < start)
			end = document.cookie.length;
		return document.cookie.substring(start, end);
	}
	return "";
}

var Cookies = document.cookie.split(";");
sub = get_cookie("sub");

if (sub=="1"){
	$(".placetab").children("a").eq(0).addClass("active").siblings().removeClass("active");
	$("#placecon" + sub).show().siblings(".placecon").hide();
}if (sub=="2"){
	$(".placetab").children("a").eq(1).addClass("active").siblings().removeClass("active");
	$("#placecon" + sub).show().siblings(".placecon").hide();
}if (sub=="3"){
	$(".placetab").children("a").eq(2).addClass("active").siblings().removeClass("active");
	$("#placecon" + sub).show().siblings(".placecon").hide();
}if (sub=="4"){
	$(".placetab").children("a").eq(3).addClass("active").siblings().removeClass("active");
	$("#placecon" + sub).show().siblings(".placecon").hide();
}

function delete_cookie(name) {
	var today = new Date();
	today.setTime(today.getTime() - 1);
	var value = get_cookie(name);
	if(value != "")
			document.cookie = name + "=" + value + "; path=/; expires=" + today.toGMTString();
}
delete_cookie("sub");

'PROGRAM > JAVASCRIPT' 카테고리의 다른 글

ie버전별 적용  (0) 2015.01.27
즐겨찾기 스크립트  (0) 2015.01.22
브라우저별 즐겨찾기  (0) 2014.05.30
input text password textarea 클릭시 텍스트 제거  (0) 2014.02.13
간단한 셀렉트 박스 링크  (0) 2014.02.05