<script
language=JavaScript>
//
쿠키생성
function setnull( name, value, expiredays )
{
var
today = new Date();
today.setDate( today.getDate() + expiredays
);
doc-ument.coo-kie = name + "=" + escape( value ) + "; path=/;
expires=" + today.toGMTString() + ";";
}
//
쿠키구하기
function getnull(name)
{
coo-kie
= doc-ument.coo-kie;
name = name +
"=";
idx =
coo-kie.indexOf(name);
if(coo-kie && idx >= 0)
{
tmp =
coo-kie.substring(idx,
coo-kie.length);
deli =
tmp.indexOf(";");
if(deli > 0)
{
return
tmp.substring(name.length, deli);
} else {
return tmp.substring(name.length);
}
}
}
// 쿠키지우기
function
clearnull(name)
{
today = new
Date();
today.setDate(today.getDate() -
1);
doc-ument.coo-kie = name + "=; path=/; expires=" +
today.toGMTString() + ";";
}
// 모든쿠키
삭제
function clearAllnull()
{
coo-kie =
doc-ument.coo-kie.split(";");
total =
coo-kie.length;
for(i=0; i<total; i++)
{
name = coo-kie[i].substring(0,
coo-kie[i].indexOf("="));
clearnull(name);
}
}
//
쿠키확인
function allnull()
{
alert(doc-ument.coo-kie);
}
</script>
<input type="button"
value="전체쿠키확인" on-click="allnull()">
<input type="button"
value="전체쿠키삭제" on-click="clearAllnull()">
<br>
<input
type="button" value="쿠키생성1" on-click="setnull('test','done',1)">
<input
type="button" value="쿠키생성2"
on-click="setnull('test2','done2',1)">
<br>
<input
type="button" value="쿠키확인1" on-click="alert(getnull('test'))">
<input
type="button" value="쿠키확인2"
on-click="alert(getnull('test2'))">
<br>
<input type="button"
value="쿠키삭제1" on-click="clearnull('test')">
<input type="button"
value="쿠키삭제2" on-click="clearnull('test2')">
'IT_Programming > JavaScript' 카테고리의 다른 글
[스크랩] Typeof연산자 (0) | 2006.04.26 |
---|---|
브라우저 내장객체 - window 객체: 새 창 관련 (0) | 2006.04.26 |
3단 트리메뉴 스크립트 (0) | 2006.04.26 |
이미지에 맞게 창 띄우기 (0) | 2006.04.26 |
날짜 선택 셀렉트박스 (0) | 2006.04.26 |