<table id=tWidth border=1 cellpatWidthing=5 cellspacing=5>
<tr bgcolor=yellow>
        <td><input type=button value="늘이기" onClick=plus()></td>
        <td><input type=button value="줄이기" onClick=minus()></td>
</tr>
</table>
<p>
<input type=button value="기본값" onClick=basic()>
.
<SCRIPT LANGUAGE="JavaScript">
<!--
/*
=====================================
이곳이 초기값 설정하는 부분입니다.
최소값은 기본값보다 100px이 작습니다.
=====================================
*/

var dSize = Number(300); // 기본값
var pSize = Number(20); // 더하고 빠지는 값
var size = Number(0);

if (getCookie("HOMESIZE"))
{
        size = Number(getCookie("HOMESIZE"))
        document.getElementById("tWidth").width = size
}
else
{
        size = dSize
        document.getElementById("tWidth").width = dSize
}

function basic() // 기본값
{          
        size = document.getElementById("tWidth").width = dSize
        deleteCookie("HOMESIZE")
}

function plus() // 늘리기
{
        size = size + pSize
        document.getElementById("tWidth").width = size
        userCookie("HOMESIZE",size,365)
}

function minus() // 줄이기
{
        if ( size > (dSize-100) ){
                size = size - pSize
                document.getElementById("tWidth").width = size
                userCookie("HOMESIZE",size,365)
        }
        else
        {
                alert ("집이 너무 작아집니다.. -_-");
        }
}

function deleteCookie(name)
{
        var expires = new Date();
        var value = getCookie(name);
        if(value)   {
                document.cookie = name + "=" + value + "; expires=" + expires.toGMTString();
        }
}

function userCookie(name,value,expire)   {
        str = '';
        str =  name + "=" + value + ( (expire) ? "; expires=" + makeGMT(expire) : "") ;
        document.cookie = str;
}

function makeGMT(stay_time)   {
        _time = new Date();
        _time.setTime(_time.getTime() + 60 * 60 * 1000 * stay_time);
        return _time.toGMTString();
}

function getCookie(wan_str)  {  
        var cs = document.cookie;  
        var prefix = wan_str + "=" ;  
        var cSI = cs.indexOf(prefix);  
        if (cSI == -1) return null;  
        else  {  
        var cEI = cs.indexOf(";", cSI + prefix.length);  
        if (cEI == -1)  ret_str =  cs.slice(cSI + prefix.length, cs.length);  
        else    ret_str = cs.slice(cSI + prefix.length, cEI);  
        }  
        return ret_str;
}

// onload = basic;

//-->
</SCRIPT>
Posted by 알 수 없는 사용자
,