2009년 10월 22일 목요일

[자바스크립트] 팝업창 로드시 세로 길이 자동 조정



<script language="JavaScript">
<!--
 function reSizePopup(){
  window.resizeTo(512, document.body.scrollHeight+30);
 }
//-->
</script>


<body marginwidth="0" marginheight="0" topmargin="0" leftmargin="0" bgcolor="#EBE3D7" onload="reSizePopup()">

2009년 10월 9일 금요일

[PHP] PHP SetCookie 사용법 (쿠키 Cookie)



Examples

Some examples follow how to send cookies:

Example #1 setcookie()>$2 send example

<?php
$value
= 'something from somewhere'
;

setcookie("TestCookie", $value
);
setcookie("TestCookie", $value, time()+3600);  
/* expire in 1 hour */
setcookie("TestCookie", $value, time()+3600, "/~rasmus/", ".example.com", 1
);
?>

Note that the value portion of the cookie will automatically be urlencoded when you send the cookie, and when it is received, it is automatically decoded and assigned to a variable by the same name as the cookie name. If you don't want this, you can use setrawcookie() instead if you are using PHP 5. To see the contents of our test cookie in a script, simply use one of the following examples:

<?php
// Print an individual cookie
echo $_COOKIE["TestCookie"
];
echo
$HTTP_COOKIE_VARS["TestCookie"
];

// Another way to debug/test is to view all cookies
print_r($_COOKIE
);
?>

Example #2 setcookie()>$2 delete example

When deleting a cookie you should assure that the expiration date is in the past, to trigger the removal mechanism in your browser. Examples follow how to delete cookies sent in previous example:

<?php
// set the expiration date to one hour ago
setcookie ("TestCookie", "", time() - 3600
);
setcookie ("TestCookie", "", time() - 3600, "/~rasmus/", ".example.com", 1
);
?>

Example #3 setcookie()>$2 and arrays

You may also set array cookies by using array notation in the cookie name. This has the effect of setting as many cookies as you have array elements, but when the cookie is received by your script, the values are all placed in an array with the cookie's name:

<?php
// set the cookies
setcookie("cookie[three]", "cookiethree"
);
setcookie("cookie[two]", "cookietwo"
);
setcookie("cookie[one]", "cookieone"
);

// after the page reloads, print them out
if (isset($_COOKIE['cookie'
])) {
    foreach (
$_COOKIE['cookie'] as $name => $value
) {
        echo
"$name : $value <br />\n"
;
    }
}
?>

The above example will output:

three : cookiethree
two : cookietwo
one : cookieone

2009년 10월 6일 화요일

[자바스크립트] 레이어 드래그 & 드롭



# 20080127 수정
 : 드래그 엘리먼트를 따로 지정할 수 있음
 : Direction 코드값 변경


사용법 : new Drag(AttributeName , DragElement , DragAreaNode , DragDirection , ScalePercentageAttributeName);
 - AttributeName : Element 클릭시 Element.getAttribute(AttributeName) 의 값이 "true" 일 때 Element를 드래그
 - DragElement : 해당 Element에 설정시 eval(Element.getAttribute(DragElement)) 를  드래그엘리먼트로 인식
 - DragAreaNode : 해당 Element에 설정시 eval(Element.getAttribute(DragAreaNode)) 하위노드에서만 드래그 가능
 - DragDirection(드래그가능방향) : Element.getAttribute(DragDirection)=[0 - Both , 1 - Horizontal , 2 - Vertical], 설정안할경우 Both
 - ScalePercentageAttributeName : Element.getAttribute(ScalePercentageAttributeName) 가 설정된 드래그 객체에 한해 DragAreaNode 로부터 Element 의 드래그범위를 설정한 비율로 리턴받을수있음(Object.ScaleX , Object.ScaleY)

 * 사용자 편의를 고려해서 최대한 각 Element의 이벤트핸들러나 기본속성에 접근하지 않는 방법을 선택했습니다. 그러다보니 거의 대부분을 사용자 확장 태그값으로 컨트롤 했는데 혹시 이 방법이 어떤 다른 이유에서 안좋다거나 하신분들은 의견 바랍니다.




<span id="text1" style="font-size:12pt;">Drag&Drop</span>

<br>

<embed id="music1" src="http://cfs9.blog.daum.net/upload_control/download.blog?fhandle=MEhUd09AZnM5LmJsb2cuZGF1bS5uZXQ6L0lNQUdFLzAvMTAud21h&filename=10.wma&filename=%ED%8B%B0%28%EC%9C%A4%EB%AF%B8%EB%9E%98%29-%EC%8B%9C%EA%B0%84%EC%9D%B4%ED%9D%90%EB%A5%B8%EB%92%A4.wma" autostart="true"></embed>

<br>

<div style="width:300px; height:300px; background:#72C31B;" draggable="true">Drag : free</div>
<div style="width:200px; height:200px; background:#FFA500; position:absolute;" id="div1" draggable="true" dragarea="document.body">dragarea : body
<input type="text" id="GridPositionX">
</div>
<div style="width:100px; height:100px; background:#FF0000;" draggable="true" dragarea="document.getElementById('div1')">dragarea : div1</div>

<img id="gridX" src="http://sstatic.naver.com/search/mypocket/v3/btn_atcmp_on_op2.gif" draggable="true" dragarea="document.getElementById('div1')" dragdirection="1" scalepercent="10000" onmousedown="return false" onmousemove="return false" title="HORIZONTAL">
<img id="gridY" src="http://sstatic.naver.com/search/mypocket/v3/btn_atcmp_on_op2.gif" draggable="true" dragarea="document.getElementById('div1')" dragdirection="2" scalepercent="500" onmousedown="return false" onmousemove="return false" title="VERTICAL">

<div id="dd" style="background:#000000; width:100px; height:100px;"><br>
<div style="background:#FFFFFF; cursor:move;" draggable="true" dragelement="document.getElementById('dd')">dragelement : parent</div>
</div>

<script language="javascript" src="Drag.js"></script>
<script language="javascript">
//기본설정
var myDrag = new Drag("draggable","dragelement","dragarea","dragdirection","scalepercent");
//기본설정

//응용설정
myDrag.addEvent(document,"onmousemove",function () {
    document.getElementById("GridPositionX").value = myDrag.ScaleX + " : " + Math.ceil(myDrag.ScaleX / 100) + "%";
    document.getElementById("music1").volume = myDrag.ScaleX - Number(document.getElementById("gridX").getAttribute("scalepercent"));
    document.getElementById("text1").style.fontSize = ((myDrag.ScaleY <= 12) ? 12 : myDrag.ScaleY) + "px";
});
//응용설정
</script>