자바스크립트로 post, get메서드의 form 전송

############# frm_test.html #############
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
<script type="text/javascript">
function createForm(frm_name,frm_method,frm_action,frm_target) {
    var f=document.createElement("form");
    f.name=frm_name;
    f.method=frm_method;
    f.action=frm_action;
    f.target=frm_target;
    return f;
}
function addHidden(f,input_type,input_name,input_id,input_value) {
    var i=document.createElement("input");
    i.type=input_type;
    i.name=input_name;
    i.id=input_id;
    i.value=input_value;
    f.insertBefore(i);
    return f;
}
var frm=createForm("frm_test", "post", "frm_test.php", "");
frm=addHidden(frm, "hidden", "mode", "mode", "login");
frm=addHidden(frm, "hidden", "id", "id", "duellist");
frm=addHidden(frm, "hidden", "password", "password", "1234");
document.insertBefore(frm);
frm.submit();
</script>
################## frm_test.php ##################
1
2
3
4
5
<?php
echo "mode : ".$_POST['mode'];
echo "id : ".$_POST['id'];
echo "password : ".$_POST['password'];
?>
################## 출력결과 ##################
mode : login
id : duellist
password : 1234



FF/IE 마우스 드래그 앤 드랍 및 이벤트 캡쳐

파이어폭스에서의 마우스 드래그 앤 드랍 및 이벤트 캡쳐
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
document.captureEvents(Event.MOUSEDOWN);
document.onmousedown=mousdownMo;
document.captureEvents(Event.MOUSEMOVE);
document.onmousemove = moveing<>
document.captureEvents(Event.MOUSEUP);
document.onmouseup = mousupMo;
 
 
function mousdownMo(event) {
    if (event.which != 1) {
        return false;
    } else {
        if (event.target.className == 'drag') {
            mousdown = true;
            x = event.clientX;
            y = event.clientY;
        }
    }
}
 
function mousupMo(event) {
    mousdown = false;
}
 
function moveingMo(event) {
    if (mousdown) {
        var distX = event.clientX - x;
        var distY = event.clientY - y;
        event.target.style.left = parseInt(event.target.style.left) + distX;
        event.target.style.top = parseInt(event.target.style.top) + distY;
        x = event.clientX;
        y = event.clientY;
        return false;
    }
}
Internet Explorer에서의 마우스 드래그 앤 드랍 및 이벤트 캡쳐
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
document.onmousedown = mousdownIe;
document.onmouseup = mmousupIe;
document.onmousemove = moveingIe;
 
 
function mousdownIe() {
    if (event.srcElement.className == 'drag') {
        mousdown = true;
        x = event.clientX;
        y = event.clientY;
    }
}
 
function mousupIe() {
    mousdown = false;
}
 
function moveingIe() {
    if (mousdown) {
        var distX = event.clientX - x;
        var distY = event.clientY - y;
        event.srcElement.style.left = parseInt(event.srcElement.style.left) + distX;
        event.srcElement.style.top = parseInt(event.srcElement.style.top) + distY;
        x = event.clientX;
        y = event.clientY;
        return false;
    }
}
1
.drag { position: absolute; cursor:move }
Return top