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

프로그래밍 >

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

프로그래밍 프로세스

스레드 작성
135 WIN API HTTP HttpSendRequest로 연결을 헀을때 내용 [0] dd 2024-12-30 10:04:37 290
dd | 2024-12-30 10:04:37 | 290 hits
134 페북 api 연동 계속에러나는데 도와주세요 [0] asd 2024-12-30 09:22:25 291
asd | 2024-12-30 09:22:25 | 291 hits
133 코더는 수학적 사고능력 없어도 할수 있냐? [0] 쑵새 2024-12-30 09:01:17 307
쑵새 | 2024-12-30 09:01:17 | 307 hits
132 c# win ce 환경에선 mpr.dll 못 쓰냐? [0] 노흑 2024-12-30 08:40:09 283
노흑 | 2024-12-30 08:40:09 | 283 hits
131 진짜 씨발 자바에서 interface가 왜 필요한지도 모르는 새끼들이 [0] ㅇㅇ 2024-12-30 07:36:21 288
ㅇㅇ | 2024-12-30 07:36:21 | 288 hits
130 서버 메모리사용량이 272128남았는데 [0] Sayrin 2024-12-30 07:15:13 279
Sayrin | 2024-12-30 07:15:13 | 279 hits
128 한국it전문학교 다닐려고하는데(진지) [0] ㅁㅁㅁ 2024-12-27 21:54:17 289
ㅁㅁㅁ | 2024-12-27 21:54:17 | 289 hits
126 1학년 여자입니다. 질문 드립니다 [0] ♡whiterabbit♡ 2024-12-27 21:11:31 266
♡whiterabbit♡ | 2024-12-27 21:11:31 | 266 hits
125 흔한 전공자의 헛된 환상 [0] ㅎㅌ 2024-12-27 20:50:22 257
ㅎㅌ | 2024-12-27 20:50:22 | 257 hits
123 신입이라면 포트폴리오를 어느정도로 해야할까요? [0] ㅋㄷㅇㅊㄹ 2024-12-27 20:08:06 280
ㅋㄷㅇㅊㄹ | 2024-12-27 20:08:06 | 280 hits
122 자동실행스크립트 해제법 아는사람? [0] ㅂㅁㅋ 2024-12-27 19:25:26 319
ㅂㅁㅋ | 2024-12-27 19:25:26 | 319 hits
121 갠작은 집에가서 하면 안됌? [0] 주변인 2024-12-27 19:04:17 272
주변인 | 2024-12-27 19:04:17 | 272 hits
120 우와야 고맙다 너때문에 해킹한새1기 역관광햇다 [0] 1 2024-12-27 18:21:32 276
1 | 2024-12-27 18:21:32 | 276 hits
118 나프사? 이책 좋음? 무슨내용임 [0] ㅇㅇ 2024-12-27 17:18:11 246
ㅇㅇ | 2024-12-27 17:18:11 | 246 hits
117 한국 it개발자 신입은 왜 죄다 파견만 뽑냐 [0] ㅇㅇ 2024-12-27 16:56:33 309
ㅇㅇ | 2024-12-27 16:56:33 | 309 hits
116 컴공에서 필수적으로 배워야되는 과목들 열거 좀 해봐라 [1] 수크라제 2024-12-27 16:35:25 296
수크라제 | 2024-12-27 16:35:25 | 296 hits
115 맨첨에 프로그래밍 배울때 배워서 뭐할라고했음??? [1] ㅇㅇ 2024-12-27 15:32:10 289
ㅇㅇ | 2024-12-27 15:32:10 | 289 hits
114 지방대 애들 겁나 무섭다 [0] ㅇㅇ 2024-12-27 14:28:55 275
ㅇㅇ | 2024-12-27 14:28:55 | 275 hits
113 C샵이 그렇게 좋냐??? [0] 1 수크라제 2024-12-27 14:07:47 309
수크라제 | 2024-12-27 14:07:47 | 309 hits
111 Django vs Ruby on Rails [0] ㅁㅈㅇㅁㅈ 2024-12-27 13:25:28 316
ㅁㅈㅇㅁㅈ | 2024-12-27 13:25:28 | 316 hits