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

프로그래밍 >

450 자바스크립트 질문좀(글 제대로 수정함) ㅇㅇ 2025-03-02 05:16:03 98
ㅇㅇ | 2025-03-02 05:16:03 | 98 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
목록 수정  삭제
목록 수정 삭제

프로그래밍 프로세스

스레드 작성
395 올댓 [0] ㅇㅇ 2025-02-26 17:12:57 146
ㅇㅇ | 2025-02-26 17:12:57 | 146 hits
393 낮부터 술마시니 별개소리다하네 [0] 북극레밍 2025-02-26 17:06:52 147
북극레밍 | 2025-02-26 17:06:52 | 147 hits
392 x86에서 carry flag나 overflow flag 체크어케하지.. [0] 니 코 가 뭐 2025-02-26 17:01:04 141
니 코 가 뭐 | 2025-02-26 17:01:04 | 141 hits
391 나 휴가나온 군인인데 군대에서 공부 이렇게 하고 있다.txt [0] dd 2025-02-26 16:59:02 154
dd | 2025-02-26 16:59:02 | 154 hits
390 여기 불고기브라더가 젤 착한듯 [0] ㅅㅂ ㅠ 2025-02-26 16:57:03 142
ㅅㅂ ㅠ | 2025-02-26 16:57:03 | 142 hits
389 님들 이거어떠캄 내컴퓨터 허벌 ㅂㅈ 되버림.. [0] 날아가욧 2025-02-26 16:46:54 131
날아가욧 | 2025-02-26 16:46:54 | 131 hits
388 c언어 기초 질문 [0] 거ㅏㅂㅈ갸ㅓ 2025-02-26 16:44:09 119
거ㅏㅂㅈ갸ㅓ | 2025-02-26 16:44:09 | 119 hits
387 유후~ [0] 778 2025-02-26 16:36:05 122
778 | 2025-02-26 16:36:05 | 122 hits
386 나프잘+윤성우 어떰 [0] ㅅㅂ ㅠ 2025-02-26 15:42:54 128
ㅅㅂ ㅠ | 2025-02-26 15:42:54 | 128 hits
385 shell script - android , done... [0] 박모씨 2025-02-26 15:28:50 154
박모씨 | 2025-02-26 15:28:50 | 154 hits
384 안녕 뉴비임 [0] 니헵 2025-02-26 15:23:59 166
니헵 | 2025-02-26 15:23:59 | 166 hits
383 서버 관리자 되고싶어요 [0] ITX 2025-02-26 15:21:43 110
ITX | 2025-02-26 15:21:43 | 110 hits
382 분명 이번 명절에도 출근하는 게이가 있겠지?? [0] 사장 2025-02-26 15:19:38 122
사장 | 2025-02-26 15:19:38 | 122 hits
381 쎅쓰들아!!!!!! [0] 사장 2025-02-26 15:15:44 148
사장 | 2025-02-26 15:15:44 | 148 hits
380 군대에서 공부하기 좋은 것 [0] 마루 2025-02-26 15:05:44 111
마루 | 2025-02-26 15:05:44 | 111 hits
379 극장에서 프갤러가 말건썰 [0] 친칠라 2025-02-26 15:03:29 124
친칠라 | 2025-02-26 15:03:29 | 124 hits
378 정보처리기사 시험 좀 어렵게 바꿔야된다 [0] 1 2025-02-26 15:01:41 120
1 | 2025-02-26 15:01:41 | 120 hits
377 토오쿄오 핫 리코더 연주 [0] 에어로홍 2025-02-26 14:59:28 131
에어로홍 | 2025-02-26 14:59:28 | 131 hits
376 Django VS Ruby on Rails [0] awdawdawd 2025-02-26 14:53:38 158
awdawdawd | 2025-02-26 14:53:38 | 158 hits
374 밑에 군대에서 뭐 공부할거 없냐는 분 여기 보셈. [0] 불고기브라더 2025-02-26 14:49:45 150
불고기브라더 | 2025-02-26 14:49:45 | 150 hits