¹æ¹®°´ÀÌ ¹æ¹®ÇÑ È½¼ö¸¦ ÄíÅ°¸¦ ÀÌ¿ëÇÏ¿© ¾ò¾î³»°í ±×¿¡ µû¸¥ ¸Þ¼¼Áö¸¦ ³ªÅ¸³À´Ï´Ù.
Script Example |
<html> <head> <script
language="JavaScript"> <!--
function getCookieVal (offset) {
var endstr = document.cookie.indexOf (";",
offset);
if (endstr == -1)
endstr = document.cookie.length;
return unescape(document.cookie.substring(offset,
endstr));
}
function GetCookie (name) {
var arg = name + "=";
var alen = arg.length;
var clen = document.cookie.length;
var i = 0;
while (i < clen) {
var j = i + alen;
if (document.cookie.substring(i, j) == arg)
return getCookieVal (j);
i = document.cookie.indexOf(" ", i) + 1;
if (i == 0)
break;
}
return null;
}
function SetCookie (name, value) {
var argv = SetCookie.arguments;
var argc = SetCookie.arguments.length;
var expires = (2 < argc) ? argv[2] : null;
var path = (3 < argc) ? argv[3] : null;
var domain = (4 < argc) ? argv[4] : null;
var secure = (5 < argc) ? argv[5] : false;
document.cookie = name + "=" + escape (value)
+
((expires == null) ? "" : ("; expires=" +
expires.toGMTString())) +
((path == null) ? "" : ("; path=" + path))
+
((domain == null) ? "" : ("; domain=" + domain))
+
((secure == true) ? "; secure" : "");
}
function DisplayInfo() {
var expdate = new Date();
var visit;
// Set expiration date to a year from now.
expdate.setTime(expdate.getTime() + (24 *
60 * 60 * 1000 * 365));
if(!(visit = GetCookie("visit")))
visit = 0;
visit++;
SetCookie("visit", visit, expdate, "/", null,
false);
var message; if(visit
== 1)
message="\n¾È³çÇϼ¼¿ä.";
if(visit == 2)
message="\n¹æ¹®ÇØ Áּż °¨»çÇÕ´Ï´Ù.";
if(visit == 3)
message="\n¶Ç ¿À¼Ì±º¿ä. °¨»çÇÕ´Ï´Ù";
if(visit == 4)
message="\nÁñ°Å¿î ÇÏ·ç°¡ µÇ¾ú³ª¿ä?";
if(visit == 5)
message="\nÀÚÁÖ ¹æ¹®ÇØ ÁÖ¼¼¿ä.";
if(visit >= 5)
message="\nÇູÇϼ¼¿ä."; alert("\n"+"¾î¼¿À¼¼¿ä.\n\n"
+"À̹øÀÌ "+visit+ "¹ø° ¹æ¹®ÀÔ´Ï´Ù." + "\n"
+message);
}
function ResetCounts() {
var expdate = new Date();
expdate.setTime(expdate.getTime() + (24 *
60 * 60 * 1000 * 365));
visit = 0;
SetCookie("visit", visit, expdate , "/", null,
false);
}
// --> </script> </HEAD>
<body onload="DisplayInfo()">
¸®·ÎµåÇÏ½Ã¸é ¹æ¹®È½¼ö°¡ ¿Ã¶ó°¡°í ÇØ´çÇÏ´Â ¹æ¹®È½¼ö¿¡ µû¶ó Àλ縻À» º¸¿©ÁÝ´Ï´Ù.
</body> </html> |
|
|
¼³¸í |
¿¹Á¦¿¡¼ ÆĶõ»ö ºÎºÐÀÌ ¹æ¹®È½¼ö¿¡ µû¸¥ Àλ縻À» ÁöÁ¤ÇÏ´Â °÷ÀÔ´Ï´Ù. 5¹ø
À̻󿡼´Â °è¼Ó ÇູÇϼ¼¿ä ¶ó´Â ¸Þ¼¼Áö°¡ ³ª¿Àµµ·Ï µÇ¾î ÀÖ½À´Ï´Ù. ´õ ¸¹Àº
¸Þ¼¼Áö¸¦ ¿øÇÏ¸é ±×¿¡ ÇØ´çÇÏ°Ô °æ¿ìÀÇ ¼ö¸¦ ´Ã·Á¼ Àλ縻À» ³Ö¾î ÁÖ¸é µË´Ï´Ù.
»¡°£»ö ºÎºÐÀÌ Ã¢ºÎºÐ¿¡ ³ªÅ¸³ª´Â ¸ä¼¼Áö¸¦ ÁöÁ¤ÇÕ´Ï´Ù. ÁÙ ¹Ù²ÞÀº \n¸¦ ÀÌ¿ëÇÏ°í
ÀÚ½ÅÀÌ ¿øÇÏ´Â ´Ù¸¥ ³»¿äÀ» Àû¿ï ¼ö ÀÖ½À´Ï´Ù. |
|
|
|
|