화면 로딩후 원하는 위치로 옮기고 싶을 때 사용하는 스크립트

 

자동으로 스크롤되기 하는 소스

다음내용을 <head>와 </head> 사이에 넣어 줍니다.




500은 위로 자동스크롤 시킬 화면의 세로 높이 10은 스크롤 속도

 

 

다음엔 에 아래의 태그를 넣어줍니다.

 

 
<body onload="scroller()"> 

 

 

위의 속성을 에 주지 않고 와 사이에 아래와 같은 폼 양식을 만들어 사용하면 페이지가 열림과 동시에 화면스크롤이 되지 않고 페이지가 열린 후 해당 단추를 눌렀을 때 화면이 스크롤 됩니다.

 

<FORM> 
<INPUT onclick=scroller() type=button value=클릭!!> 
</FORM> 

 

 

 

 

 

AND

 

 

 Php를 사용 할 수 없는 환경에서 간단하게 자바를 이용한 인클루드 스크립트가 있어서

소개하려 한다.

 

 

include-me.html

 

   

Hello, world!

 

 

인클루드 페이지

 

   

 

csi.js-master.zip 

 

 

AND

 

 

날짜 시간 계산 예제

 

 

import java.util.*;
import java.text.*;
public class StringToDate {
public static void main(String[] args) {
try { String str_date="2010-07-09T12:50:58";
DateFormat formatter ; 
Date date ;
formatter = new SimpleDateFormat("yyyy-MM-dd'T'hh:mm:ss");
date = (Date)formatter.parse(str_date);
System.out.println("Today is " +date );
} catch (ParseException e)
{System.out.println("Exception :"+e); }
}
}

 

 

 

Java에서 내가 알고 있는 시간과 관련된 클래스는 다음의 세가지가 있다.


Calendar

날짜와 요일 관련하여 유용한 기능들을 가진 클래스이다. 달력을 그리거나, 오늘이 한달중에서 몇번째 주이고 몇번째 요일인지 계산하는 기능들을 가지고 있다. 단, 시간 정확도는 분까지만 보장한다. 날짜 수준까지만 사용하는 것을 권장한다.


Date

날짜를 구하는 클래스이다. API문서에는 milisecond 수준까지 정확도를 보장한다고 되어 있다. 하지만 메소드중 많은 메소드가 deprecated(권장하지 않음)이기 때문에, 날짜 계산이 필요할 경우에는 Calendar클래스의 add(int, int)를 사용하고, millisecond 단위로 계산할때는 System.getCurrentTimemilis()를 권장한다.


System.getCurrentTimemilis()

국제표준시각(UTC, GMT) 1970/1/1/0/0/0 으로부터 경과한 시각을 밀리초 단위까지 계산하여 long 값으로 반환한다. 주로 정확한 시간 계산이 필요한 경우에 해당 메서드를 주로 사용한다. 필요한 경우 Date클래스나 Calendar 클래스로 변환하여 사용할 수 있다.

 

아래는 Calendar 클래스의 사용법이다.

 

//현재 날짜를 받아옴. 

Calendar t = Calendar.getInstance();

//오늘날짜의 해당연도를 구함

String year = Integer.toString(t.get(Calendar.YEAR));

//오늘날짜의 해당 월을 구함. 1월은 0이기 때문에 + 1

String month = Integer.toString((t.get(Calendar.MONTH) + 1));

//한자리 숫자, 예를 들면 1월인 경우 "01"등으로 문자열 변환

month = month.length() > 1 ? month : "0" + month;

//오늘의 날짜 구함

String day = Integer.toString(t.get(Calendar.DAY_OF_MONTH));

day = day.length() > 1 ? day : "0" + day;

//현재 시각의 시를 구함.

String hh = Integer.toString(t.get(Calendar.HOUR_OF_DAY));

//현재 시각의 분을 구함.

String mm = Integer.toString(t.get(Calendar.MINUTE));

//오늘의 요일을 구함

String WeekDay = Integer.toString(t.get(Calendar.DAY_OF_WEEK));

//오늘이 1~5번째 주중 몇번째 주인지 구함. 

String WeekOfMonth = Integer.toString(t.get(Calendar.WEEK_OF_MONTH);

//오늘을 기준으로 3주전 날짜로 수정



t.add(Calendar.WEEK_OF_MONTH, -3);

 

 

 

 

아래는 Date 클래스의 사용법이다.

 

 

//현재 시각 가져오기.

Date today = new Date (); 

//출력

System.out.println ( today );

//시작일. 여기서는 샘플로 24시간 전의 시각을 지정.

Date startDay = new Date(System.currentTimeMillis() - 1000*60*60*24);

//종료일. 여기서는 샘플로 24시간 후의 시각을 지정.

Date endDay = new Date(System.currentTimeMillis() - 1000*60*60*24);

//해당 기간 조회

if(startDate.before(today) && endDate.after(today))

{

 System.out.pringln("지정하신 날짜는 해당 기간내에 존재합니다.");

}

 


 

출처: http://blog.naver.com/vlueguy7/70096153885

AND

자바스크립트를 이용한 날짜, 시간 계산 예제 모음

 

 

시스템의 밀리초 구하기.(국제표준시각(UTC, GMT) 1970/1/1/0/0/0 으로부터 경과한 시각)

 

// 밀리초 단위(*1000은 1초), 음수이면 이전 시각
long time = System.currentTimeMillis ( ); 
System.out.println ( time.toString ( ) ); 

 

 

현재 시각을 가져오기.

 

Date today = new Date (); 
System.out.println ( today );

결과 : Sat Jul 12 16:03:00 GMT+01:00 2000

 

 

경과시간(초) 구하기

 

long time1 = System.currentTimeMillis (); 
long time2 = System.currentTimeMillis ();
system.out.println ( ( time2 - time1 ) / 1000.0 );

 

 

Date를 Calendar로 맵핑하기

 

Date d = new Date ( );
Calendar c = Calendar.getInstance ( );
c.setTime ( d );

 

 

날짜(년/월/일/시/분/초) 구하기

 

import java.util.*;
import java.text.*; 


SimpleDateFormat formatter = new SimpleDateFormat ( "yyyy.MM.dd HH:mm:ss", Locale.KOREA );
Date currentTime = new Date ( );
String dTime = formatter.format ( currentTime );
System.out.println ( dTime ); 

 

 

날짜(년/월/일/시/분/초) 구하기2

 

GregorianCalendar today = new GregorianCalendar ( ); 


int year = today.get ( today.YEAR );
int month = today.get ( today.MONTH ) + 1;
int yoil = today.get ( today.DAY_OF_MONTH ); 


GregorianCalendar gc = new GregorianCalendar ( );


System.out.println ( gc.get ( Calendar.YEAR ) );
System.out.println ( String.valueOf ( gc.get ( Calendar.MONTH ) + 1 ) );
System.out.println ( gc.get ( Calendar.DATE ) );
System.out.println ( gc.get ( DAY_OF_MONTH ) ); 

 

 

날짜(년/월/일/시/분/초) 구하기3

 

DateFormat df = DateFormat.getDateInstance(DateFormat.LONG, Locale.KOREA);
Calendar cal = Calendar.getInstance(Locale.KOREA);
nal = df.format(cal.getTime()); 

 

 

- 표준시간대를 지정하고 날짜를 가져오기.

 

TimeZone jst = TimeZone.getTimeZone ("JST");
Calendar cal = Calendar.getInstance ( jst ); // 주어진 시간대에 맞게 현재 시각으로 초기화된 GregorianCalender 객체를 반환.// 또는 Calendar now = Calendar.getInstance(Locale.KOREA);
System.out.println ( cal.get ( Calendar.YEAR ) + "년 " + ( cal.get ( Calendar.MONTH ) + 1 ) + "월 " + cal.get ( Calendar.DATE ) + "일 " + cal.get ( Calendar.HOUR_OF_DAY ) + "시 " +cal.get ( Calendar.MINUTE ) + "분 " + cal.get ( Calendar.SECOND ) + "초 " );

결과 : 2000년 8월 5일 16시 16분 47초

 

 

영어로된 날짜를 숫자로 바꾸기

 

Date myDate = new Date ( "Sun,5 Dec 1999 00:07:21" ); 
System.out.println ( myDate.getYear ( ) + "-" + myDate.getMonth ( ) + "-" + myDate.getDay ( ) ); 

 

 

"Sun, 5 Dec 1999 00:07:21"를 "1999-12-05"로 바꾸기

 

SimpleDateFormat formatter_one = new SimpleDateFormat ( "EEE, dd MMM yyyy hh:mm:ss",Locale.ENGLISH );
SimpleDateFormat formatter_two = new SimpleDateFormat ( "yyyy-MM-dd" ); 


String inString = "Sun, 5 Dec 1999 00:07:21"; 


ParsePosition pos = new ParsePosition ( 0 );
Date frmTime = formatter_one.parse ( inString, pos );
String outString = formatter_two.format ( frmTime );


System.out.println ( outString ); 

 

 

숫자 12자리를, 다시 날짜로 변환하기

 

Date conFromDate = new Date();
long ttl = conFromDate.parse ( "Dec 25, 1997 10:10:10" );
System.out.println ( ttl ); //예 938291839221 


Date today = new Date ( ttl );
DateFormat format = DateFormat.getDateInstance ( DateFormat.FULL,Locale.US );
String formatted = format.format ( today );
System.out.println ( formatted ); 

특정일로부터 n일 만큼 이동한 날짜 구하기 특정일의 시간을 long형으로 읽어온다음.. 날짜*24*60*60*1000 을 계산하여. long형에 더해줍니다. 그리고 나서 Date클래스와 Calender클래스를 이용해서 날짜와 시간을 구하면 됩니다

 

 

특정일에서 일정 기간후의 날짜 구하기2

 

//iDay 에 입력하신 만큼 빼거나 더한 날짜를 반환 합니다.
import java.util.*; 


public String getDate ( int iDay ) 
{
Calendar temp=Calendar.getInstance ( );
StringBuffer sbDate=new StringBuffer ( );


temp.add ( Calendar.DAY_OF_MONTH, iDay );


int nYear = temp.get ( Calendar.YEAR );
int nMonth = temp.get ( Calendar.MONTH ) + 1;
int nDay = temp.get ( Calendar.DAY_OF_MONTH );


sbDate.append ( nYear );
if ( nMonth < 10 ) 
sbDate.append ( "0" );
sbDate.append ( nMonth );
if ( nDay < 10 ) 
sbDate.append ( "0" );
sbDate.append ( nDay );


return sbDate.toString ( );
} 

 

 

현재날짜에서 2달전의 날짜를 구하기

 

Calendar cal = Calendar.getInstance ( );//오늘 날짜를 기준으루..
cal.add ( cal.MONTH, -2 ); //2개월 전....
System.out.println ( cal.get ( cal.YEAR ) );
System.out.println ( cal.get ( cal.MONTH ) + 1 );
System.out.println ( cal.get ( cal.DATE ) );

 

 

달에 마지막 날짜 구하기

 

for ( int month = 1; month <= 12; month++ ) 
{
GregorianCalendar cld = new GregorianCalendar ( 2001, month - 1, 1 );
System.out.println ( month + "/" + cld.getActualMaximum ( Calendar.DAY_OF_MONTH ) );
}

 

 

해당하는 달의 마지막 일 구하기

 

GregorianCalendar today = new GregorianCalendar ( );
int maxday = today.getActualMaximum ( ( today.DAY_OF_MONTH ) );
System.out.println ( maxday );

 

 

특정일을 입력받아 해당 월의 마지막 날짜를 구하는 간단한 예제.(달은 -1 해준다.)...윤달 30일 31일 알아오기.

 

Calendar cal = Calendar.getInstance ( );
cal.set ( Integer.parseInt ( args[0] ), Integer.parseInt ( args [1] ) - 1, Integer.parseInt ( args [2] ) );
SimpleDateFormat dFormat = new SimpleDateFormat ( "yyyy-MM-dd" );
System.out.println ( "입력 날짜 " + dFormat.format ( cal.getTime ( ) ) );
System.out.println ( "해당 월의 마지막 일자 : " + cal.getActualMaximum ( Calendar.DATE ) );

 

 

해당월의 실제 날짜수 구하기 ( 1999년 1월달의 실제 날짜수를 구하기 )

 

Calendar calendar = Calendar.getInstance ( );
calendar.set ( 1999, 0, 1 );
int maxDays = calendar.getActualMaximum ( Calendar.DAY_OF_MONTH );

 

 

어제 날짜 구하기 오늘날짜를 초단위로 구해서 하루분을 빼주고 다시 셋팅해주면 쉽게 구할수 있죠.. setTime((기준일부터 오늘까지의 초를 구함) - 24*60*60)해주면 되겠죠.. 어제 날짜 구하기2

 

import java.util.*; 


public static Date getYesterday ( Date today )
{
if ( today == null ) 
throw new IllegalStateException ( "today is null" );
Date yesterday = new Date ( );
yesterday.setTime ( today.getTime ( ) - ( (long) 1000 * 60 * 60 * 24 ) );


return yesterday;
} 

 

 

내일 날짜 구하기

 

Date today = new Date ( );
Date tomorrow = new Date ( today.getTime ( ) + (long) ( 1000 * 60 * 60 * 24 ) );

 

 

내일 날짜 구하기2

 

Calendar today = Calendar.getInstance ( );
today.add ( Calendar.DATE, 1 );
Date tomorrow = today.getTime ( );

 

 

오늘날짜에서 5일 이후 날짜를 구하기

 

Calendar cCal = Calendar.getInstance();
c.add(Calendar.DATE, 5);

 

 

날짜에 해당하는 요일 구하기

 

//DAY_OF_WEEK리턴값이 일요일(1), 월요일(2), 화요일(3) ~~ 토요일(7)을 반환합니다. 
//아래 소스는 JSP일부입니다.
import java.util.*; 


Calendar cal= Calendar.getInstance ( );
int day_of_week = cal.get ( Calendar.DAY_OF_WEEK );
if ( day_of_week == 1 )
m_week="일요일";
else if ( day_of_week == 2 )
m_week="월요일";
else if ( day_of_week == 3 )
m_week="화요일";
else if ( day_of_week == 4 )
m_week="수요일";
else if ( day_of_week == 5 )
m_week="목요일";
else if ( day_of_week == 6 )
m_week="금요일";
else if ( day_of_week == 7 )
m_week="토요일"; 

 

 

콤보박스로 선택된 날짜(예:20001023)를 통해 요일을 영문으로 가져오기

 

//gc.get(gc.DAY_OF_WEEK); 하면 일요일=1, 월요일=2, ..., 토요일=7이 나오니까, 
//요일을 배열로 만들어서 뽑아내면 되겠죠. 
GregorianCalendar gc=new GregorianCalendar ( 2000, 10 - 1 , 23 ); 
String [] dayOfWeek = { "", "Sun", "Mon", .... , "Sat" }; 
String yo_il = dayOfWeek ( gc.get ( gc.DAY_OF_WEEK ) ); 

두 날짜의 차이를 일수로 구하기 각각의 날짜를 Date형으로 만들어서 getTime()하면 long으로 값이 나오거든요(1970년 1월 1일 이후-맞던가?- 1/1000 초 단위로..) 그러면 이값의 차를 구해서요. (1000*60*60*24)로 나누어 보면 되겠죠.

 

 

두 날짜의 차이를 일수로 구하기2

 

import java.io.*;
import java.util.*; 


Date today = new Date ( );
Calendar cal = Calendar.getInstance ( );
cal.setTime ( today );// 오늘로 설정. 


Calendar cal2 = Calendar.getInstance ( );
cal2.set ( 2000, 3, 12 ); // 기준일로 설정. month의 경우 해당월수-1을 해줍니다.


int count = 0;
while ( !cal2.after ( cal ) )
{
count++;
cal2.add ( Calendar.DATE, 1 ); // 다음날로 바뀜


System.out.println ( cal2.get ( Calendar.YEAR ) + "년 " + ( cal2.get ( Calendar.MONTH ) + 1 ) + "월 " + cal2.get ( Calendar.DATE ) + "일" );
}


System.out.println ( "기준일로부터 " + count + "일이 지났습니다." ); 

 

 

두 날짜의 차이를 일수로 구하기3

 

import java.io.*;
import java.util.*; 


public class DateDiff
{
public static int GetDifferenceOfDate ( int nYear1, int nMonth1, int nDate1, int nYear2, int nMonth2, int nDate2 )
{
Calendar cal = Calendar.getInstance ( );
int nTotalDate1 = 0, nTotalDate2 = 0, nDiffOfYear = 0, nDiffOfDay = 0;


if ( nYear1 > nYear2 )
{
for ( int i = nYear2; i < nYear1; i++ ) 
{
cal.set ( i, 12, 0 );
nDiffOfYear += cal.get ( Calendar.DAY_OF_YEAR );
}
nTotalDate1 += nDiffOfYear;
}
else if ( nYear1 < nYear2 )
{
for ( int i = nYear1; i < nYear2; i++ )
{
cal.set ( i, 12, 0 );
nDiffOfYear += cal.get ( Calendar.DAY_OF_YEAR );
}
nTotalDate2 += nDiffOfYear;
}


cal.set ( nYear1, nMonth1-1, nDate1 );
nDiffOfDay = cal.get ( Calendar.DAY_OF_YEAR );
nTotalDate1 += nDiffOfDay;


cal.set ( nYear2, nMonth2-1, nDate2 );
nDiffOfDay = cal.get ( Calendar.DAY_OF_YEAR );
nTotalDate2 += nDiffOfDay;


return nTotalDate1-nTotalDate2;
} 


public static void main ( String args[] )
{
System.out.println ( "" + GetDifferenceOfDate (2000, 6, 15, 1999, 8, 23 ) );
}
} 

 

 

파일에서 날짜정보를 가져오기

 

File f = new File ( directory, file ); 


Date date = new Date ( f.lastModified ( ) );
Calendar cal = Calendar.getInstance ( );
cal.setTime ( date );


System.out.println("Year : " + cal.get(Calendar.YEAR));
System.out.println("Month : " + (cal.get(Calendar.MONTH) + 1));
System.out.println("Day : " + cal.get(Calendar.DAY_OF_MONTH));
System.out.println("Hours : " + cal.get(Calendar.HOUR_OF_DAY));
System.out.println("Minutes : " + cal.get(Calendar.MINUTE));
System.out.println("Second : " + cal.get(Calendar.SECOND)); 

 

 

날짜형식으로 2000-01-03으로 처음에 인식을 시킨후 7일씩 증가해서 1년정도의 날짜를 출력해 주고 싶은데요.

 

SimpleDateFormat sdf = new SimpleDateFormat ( "yyyy-mm-dd" );
Calendar c = Calendar.getInstance ( ); 


for ( int i = 0; i < 48; i++ )
{
c.clear ( );
c.set ( 2000, 1, 3 - ( i * 7 ) );
java.util.Date d = c.getTime ( );
String thedate = sdf.format ( d );
System.out.println ( thedate );
}  

 

 

쓰레드에서 날짜 바꾸면 죽는 문제 Main화면에 날짜와시간이Display되는 JPanel이 있습니다. date로 날짜와 시간을 변경하면 Main화면의 날짜와 시간이 Display되는 Panel에 변경된 날짜가 Display되지 않고 Main화면이 종료되어 버립니다. 문제소스:

 

public void run ( )
{
while ( true )
{
try{
timer.sleep ( 60000 );
}
catch ( InterruptedException ex ) { } 


lblTimeDate.setText ( fGetDateTime ( ) ); 
repaint ( );
}
}


public String fGetDateTime ( )
{
final int millisPerHour = 60 * 60 * 1000;
String DATE_FORMAT = "yyyy / MM / dd HH:mm";
SimpleDateFormat sdf = new SimpleDateFormat ( DATE_FORMAT );
SimpleTimeZone timeZone = new SimpleTimeZone ( 9 * millisPerHour, "KST" );
sdf.setTimeZone ( timeZone );


long time = System.currentTimeMillis ( );
Date date = new Date ( time );
return sdf.format ( date );
} 
해답:
// 날짜와 요일 구한다. timezone 으로 날짜를 다시 셋팅하시면 됨니다.
public String getDate ( )
{
Date now = new Date ( );
SimpleDateFormat sdf4 = new SimpleDateFormat ( "yyyy/MM/dd HH:mm EE" );
sdf4.setTimeZone ( TimeZone.getTimeZone ( "Asia/Seoul" ) ); 


return sdf4.format ( now );
} 

 

 

날짜와 시간이 유효한지 검사하려면...?

 

import java.util.*;
import java.text.*; 


public class DateCheck 
{
boolean dateValidity = true;


DateCheck ( String dt )
{ 
try 
{
DateFormat df = DateFormat.getDateInstance ( DateFormat.SHORT );
df.setLenient ( false ); 
Date dt2 = df.parse ( dt ); 
}
catch ( ParseException e ) { this.dateValidity = false; }
catch ( IllegalArgumentException e ) { this.dateValidity = false; }
} 


public boolean datevalid ( )
{ 
return dateValidity;
}


public static void main ( String args [] ) 
{
DateCheck dc = new DateCheck ( "2001-02-28" );
System.out.println ( " 유효한 날짜 : " + dc.datevalid ( ) );
}
} 

 

두 날짜 비교하기(아래보다 정확) 그냥 날짜 두개를 long(밀리 세컨드)형으로 비교하시면 됩니다... 이전의 데이타가 date형으로 되어 있다면, 이걸 long형으로 변환하고. 현재 날짜(시간)은 System.currentTimeMillis()메소드로 읽어들이고, 두수(long형)를 연산하여 그 결과 값으로 비교를 하시면 됩니다. 만약 그 결과값이 몇시간 혹은 며칠차이가 있는지를 계산할려면, 결과값을 Calender의 setTimeInMillis(long millis) 메소드를 이용해 설정한다음 각각의 날짜나 시간을 읽어오시면 됩니다

 

 

두 날짜 비교하기2

 

//Calendar를 쓸 경우 데이타의 원본을 고치기 때문에 clone()을 사용하여 
//복사한 후에 그 복사본을 가지고 비교한다
import java.util.*;
import java.util.Calendar.*;
import java.text.SimpleDateFormat; 


public class DayComparisonTest
{
public static void main(String args[])
{
Calendar cal = Calendar.getInstance();
SimpleDateFormat dateForm = new SimpleDateFormat("yyyy-MM-dd");


Calendar aDate = Calendar.getInstance(); // 비교하고자 하는 임의의 날짜
aDate.set(2001, 0, 1);


Calendar bDate = Calendar.getInstance(); // 이것이 시스템의 날짜


// 여기에 시,분,초를 0으로 세팅해야 before, after를 제대로 비교함
aDate.set( Calendar.HOUR_OF_DAY, 0 );
aDate.set( Calendar.MINUTE, 0 );
aDate.set( Calendar.SECOND, 0 );
aDate.set( Calendar.MILLISECOND, 0 );


bDate.set( Calendar.HOUR_OF_DAY, 0 );
bDate.set( Calendar.MINUTE, 0 );
bDate.set( Calendar.SECOND, 0 );
bDate.set( Calendar.MILLISECOND, 0 );

if (aDate.after(bDate)) // aDate가 bDate보다 클 경우 출력
System.out.println("시스템 날짜보다 뒤일 경우 aDate = " + dateForm.format(aDate.getTime())); 
else if (aDate.before(bDate)) // aDate가 bDate보다 작을 경우 출력
System.out.println("시스템 날짜보다 앞일 경우 aDate = " + dateForm.format(aDate.getTime()));
else // aDate = bDate인 경우
System.out.println("같은 날이구만");
}
}  

 

 

 

 

출처: http://www.yunsobi.com/blog/325

 

AND

 

 

웹사이트 작업시 꼭 필요한 기능중 하나가 쿠키관련 제어입니다.

하지만 자바스크립트에서 관련 함수가 마련되어있지 않아서 번거롭게 하죠.

 

자주 사용하게 되는 쿠키 값 설정과 읽기 함수를 올려드립니다.

 

아래는 쿠키값 읽기 함수 입니다.

t_val = getCookie('itemname');

과 같은 형식으로 이용하시면 됩니다.

 

function getCookie(c_name)

{

 var i,x,y,ARRcookies=document.cookie.split(";");

 for (i=0;i<ARRcookies.length;i++)

 {

  x=ARRcookies[i].substr(0,ARRcookies[i].indexOf("="));

  y=ARRcookies[i].substr(ARRcookies[i].indexOf("=")+1);

  x=x.replace(/^\s+|\s+$/g,"");

  if (x==c_name)

  {

  return unescape(y);

  }

  }

}

 

 

아래는 쿠키값 설정 함수 입니다.

setCookie('itemname','설정값',1);

과 같은 형태로 이용하시면 되며, 3번째 값은 유지되는 기간입니다.

3번째 값을 설정하지 않으시면 브라우져가 열려있는 동안 유지되며, 위의 예와 같이 1로 설정하시면 하루동안 유지됩니다

 

function setCookie(c_name,value,exdays)

{

 var exdate=new Date();

 exdate.setDate(exdate.getDate() + exdays);

 var c_value=escape(value) + ((exdays==null) ? "" : "; expires="+exdate.toUTCString());

 document.cookie=c_name + "=" + c_value;

}

 


 

원문출처 : http://shub.tistory.com/180

AND