배경 색상바꾸기~
본문
<style type=text/css>
.colorbox { font-size: 7px; margin: 2px; cursor:pointer; width:10px; height:10px; border: #AAAAAA 1px solid; }
</style>
<script language="javascript">
function changeBg (obj) {
var color = obj.style.backgroundColor;
document.body.style.backgroundColor = color;
setCookie('bgcolor',color,365);
}
function setCookie(name,value,expiredays)
{
var todayDate = new Date();
todayDate.setDate(todayDate.getDate() + expiredays);
document.cookie = name + "=" + escape(value) + "; path=/; expires=" + todayDate.toGMTString() + ";"
}
</script>
<div title="주변색 바꾸기"><span class="colorbox" style="background-color:#FFFFFF" onclick="changeBg(this);"> </span><span class="colorbox" style="background-color:#ECECEC" onclick="changeBg(this);"> </span><span class="colorbox" style="background-color:#ECFCD2" onclick="changeBg(this);"> </span><span class="colorbox" style="background-color:#FFFECB" onclick="changeBg(this);"> </span><span class="colorbox" style="background-color:#EBD4F7" onclick="changeBg(this);"> </span><span class="colorbox" style="background-color:#B4BFCC" onclick="changeBg(this);"> </span><span class="colorbox" style="background-color:#FF943D" onclick="changeBg(this);"> </span><span class="colorbox" style="background-color:#0099FF" onclick="changeBg(this);"> </span><span class="colorbox" style="background-color:#8EDC0C" onclick="changeBg(this);"> </span><span class="colorbox" style="background-color:#000099" onclick="changeBg(this);"> </span><span class="colorbox" style="background-color:#000000" onclick="changeBg(this);"> </span><span class="colorbox" style="background-color:#C7141A" onclick="changeBg(this);"> </span></div>
.colorbox { font-size: 7px; margin: 2px; cursor:pointer; width:10px; height:10px; border: #AAAAAA 1px solid; }
</style>
<script language="javascript">
function changeBg (obj) {
var color = obj.style.backgroundColor;
document.body.style.backgroundColor = color;
setCookie('bgcolor',color,365);
}
function setCookie(name,value,expiredays)
{
var todayDate = new Date();
todayDate.setDate(todayDate.getDate() + expiredays);
document.cookie = name + "=" + escape(value) + "; path=/; expires=" + todayDate.toGMTString() + ";"
}
</script>
<div title="주변색 바꾸기"><span class="colorbox" style="background-color:#FFFFFF" onclick="changeBg(this);"> </span><span class="colorbox" style="background-color:#ECECEC" onclick="changeBg(this);"> </span><span class="colorbox" style="background-color:#ECFCD2" onclick="changeBg(this);"> </span><span class="colorbox" style="background-color:#FFFECB" onclick="changeBg(this);"> </span><span class="colorbox" style="background-color:#EBD4F7" onclick="changeBg(this);"> </span><span class="colorbox" style="background-color:#B4BFCC" onclick="changeBg(this);"> </span><span class="colorbox" style="background-color:#FF943D" onclick="changeBg(this);"> </span><span class="colorbox" style="background-color:#0099FF" onclick="changeBg(this);"> </span><span class="colorbox" style="background-color:#8EDC0C" onclick="changeBg(this);"> </span><span class="colorbox" style="background-color:#000099" onclick="changeBg(this);"> </span><span class="colorbox" style="background-color:#000000" onclick="changeBg(this);"> </span><span class="colorbox" style="background-color:#C7141A" onclick="changeBg(this);"> </span></div>
그리고 페이지의 body 태그위에 아래 php 소스를 넣고 다음과 같이 꾸며줍니다.
<?PHP
if(isset($_COOKIE['bgcolor'])) {
$bgcolor = urldecode($_COOKIE['bgcolor']);
} else {
$bgcolor = "#FFFFFF"; //설정하기전 기본 색상
}
?>
if(isset($_COOKIE['bgcolor'])) {
$bgcolor = urldecode($_COOKIE['bgcolor']);
} else {
$bgcolor = "#FFFFFF"; //설정하기전 기본 색상
}
?>
<body bgcolor="<?=$bgcolor?>">
출처 : http://www.aircon1004.com/data/bbs/board.php?bo_table=pds1&wr_id=169
관련링크
댓글목록
등록된 댓글이 없습니다.