Sample Image
공지: 보이드리얼리티 베타 서비스가 시작 됐습니다. (2025-03-09 13:13:36)

프로그래밍 >

450 자바스크립트 질문좀(글 제대로 수정함) ㅇㅇ 2025-03-02 05:16:03 96
ㅇㅇ | 2025-03-02 05:16:03 | 96 hits

test2.html  코드임




<!DOCTYPE html>
<html>
<head>
<title>test</title>
<style>
form {
    width: 330px;
    margin: 20px;
    background-color: pink;
    Padding: 20px;
}

input {
    text-align: right;
}
</style>

<script type="text/javascript">





    var pw;
    function create_form(_name, _action, _method, _target) {

        var instance = document.createElement("form");
        instance.name = _name;
        instance.action = _action;
        instance.method = _method;
        instance.target = _target;

        return instance;
    }

    function create_input_to_form(_form, _type, _name, _value) {
        var form_instance = _form;
        var input_instance = document.createElement("input");

        input_instance.type = _type;
        input_instance.name = _name;
        input_instance.value = _value;

        form_instance.insertBefore(input_instance, null);

        return form_instance;
    }

    function insert_form_to_html(_form) {
        document.body.insertBefore(_form, null);
    }

    function init() {
        var instance = create_form("nuForm", "Test3.html", "post", "postWindow");
        insert_form_to_html(instance);
        pw = window.open("", "postWindow", "width=300, height=400");
        instance.submit();

        if (pw == null) {
            alert("error;");
        } else {


            pw.onload = function() {
                alert("wow2");
                console.log("4");
            }
            console.log("2");
            console.log(pw);
            setTimeout(function() {
                if (pw==null) {
                    alert("pw is null");
                }
                else {
                    //console.log(document.domain);
                    console.log(pw);
                    //alert(pw.title);
                }

            }, 3000);
            console.log("3");
        }

    }
</script>
</head>

<body onLoad="init();">

</body>
</html>  



test3.html 코드임

<!DOCTYPE html>
<html>
<head>
<title>Insert title here</title>
</head>
<body>popup bodys
</body>
</html>


첫번째문제는 pw값이 setTimeout()시점에서 증발해버린다느점이고(pw 전역변수임 보다시피)

두번째문제는 pw.onload가 팝업창이 완전히 다 열리고 나서까지도 실행이 안된다는거임


참고로 구글크롬 콘솔 내용은 다음과같다

2 Test2.html:69

'window.webkitStorageInfo' is deprecated. Please use 'navigator.webkitTemporaryStorage' or 'navigator.webkitPersistentStorage' instead. VM56:423

Window {top: Window, window: Window, location: Location, external: Object, chrome: Object…}

 Test2.html:70

3 Test2.html:82

Window {} 






ㅁㄴㅇㅁㄴㅇㅁㄴㅇㅁㄴㅇㅁㄴㅇ

(^오^) "Cool~" 0 | (-_-) "Damn!" 0
목록 수정  삭제
목록 수정 삭제

프로그래밍 프로세스

스레드 작성
525 내가 우파 지지하는 이유 [0] ㅁㄴ 2025-03-09 14:45:54 89
ㅁㄴ | 2025-03-09 14:45:54 | 89 hits
524 설마 오늘 일하는 사람 있는건 아니겠지????????????? [1] ㅇㅇ 2025-03-09 13:11:24 59
ㅇㅇ | 2025-03-09 13:11:24 | 59 hits
523 이거 사실인가요? - 한국의 네트워크 [0] 에어로홍 2025-03-09 11:37:51 59
에어로홍 | 2025-03-09 11:37:51 | 59 hits
522 Django vs Ruby on Rails [0] ct 2025-03-09 08:30:49 68
ct | 2025-03-09 08:30:49 | 68 hits
521 다른건몰라도 IT 땔감만들어낸건 김대중임 [0] 2025-03-09 06:57:18 51
| 2025-03-09 06:57:18 | 51 hits
520 이거 sql맞음? [0] 김유식 2025-03-09 05:23:35 75
김유식 | 2025-03-09 05:23:35 | 75 hits
519 지잡대와 명문대의차이는... [0] 2025-03-09 03:50:08 74
| 2025-03-09 03:50:08 | 74 hits
518 일단 대학 수를 줄여야지 [0] ㅁㄴㅇ 2025-03-09 02:16:32 78
ㅁㄴㅇ | 2025-03-09 02:16:32 | 78 hits
517 겨울왕국보세요 여러분 [0] 1 黑猫 2025-03-09 00:43:11 66
黑猫 | 2025-03-09 00:43:11 | 66 hits
516 김대중 선생님이 왜 욕먹어야되냐? [0] 2025-03-08 23:09:49 90
| 2025-03-08 23:09:49 | 90 hits
515 지잡은 솔직히 지잡다니는 애들이 잘~ 알잖아 너네는 어떤지 몰라도 [0] ㅇㅇ 2025-03-08 20:02:50 76
ㅇㅇ | 2025-03-08 20:02:50 | 76 hits
514 컴공에만 특혜주면 안되나? [0] 불고기브라더 2025-03-08 18:29:19 85
불고기브라더 | 2025-03-08 18:29:19 | 85 hits
513 웹 코딩하는데 좋은컴퓨터 쓸 이유가 도대체 뭐가 있지 [0] ㅇㅇ 2025-03-08 16:55:56 95
ㅇㅇ | 2025-03-08 16:55:56 | 95 hits
512 탭북으로 컴공 2학년 과정 버틸 수 있냐 [0] 갖고싶다홍석천 2025-03-08 15:22:35 69
갖고싶다홍석천 | 2025-03-08 15:22:35 | 69 hits
511 컴공이 쓰레기가 아니라 지잡이 쓰레기라고 [0] ㅇㅇ 2025-03-08 13:49:13 88
ㅇㅇ | 2025-03-08 13:49:13 | 88 hits
510 불법소프트웨어 단속은 나오는데 근로감독은 안 나오더라 [0] ㅁㄹ 2025-03-08 12:15:34 87
ㅁㄹ | 2025-03-08 12:15:34 | 87 hits
508 정치글 올려도 괜춘한데 개대중이만 찬양하지만 않으면 된다. [0] 씹죶 2025-03-08 09:08:20 91
씹죶 | 2025-03-08 09:08:20 | 91 hits
507 임진왜란때 전쟁은 명나라군대가 다하고 [0] hongiro 2025-03-08 06:01:20 93
hongiro | 2025-03-08 06:01:20 | 93 hits
506 진짜 니네 플밍 배워서 어따 써먹을래? [0] ㅁㅇ 2025-03-08 04:27:49 87
ㅁㅇ | 2025-03-08 04:27:49 | 87 hits
505 컴공 존낰ㅋㅋㅋㅋㅋㅋㅋㅋ [0] ㅇㅇ 2025-03-08 01:20:59 65
ㅇㅇ | 2025-03-08 01:20:59 | 65 hits