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

프로그래밍 >

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

프로그래밍 프로세스

스레드 작성
42 안녕 뉴비임 [0] 니헵 2024-12-23 09:24:23 303
니헵 | 2024-12-23 09:24:23 | 303 hits
41 C언어 질문입니다. [0] 알려주세요 2024-12-20 17:39:21 340
알려주세요 | 2024-12-20 17:39:21 | 340 hits
40 어셈으로 CPU마비 가능? [0] 고정닉없다고 2024-12-20 16:57:10 334
고정닉없다고 | 2024-12-20 16:57:10 | 334 hits
39 컴공은 1억이상 받으려면 사업밖에 없냐? [0] ㅇㅇ 2024-12-20 16:36:02 309
ㅇㅇ | 2024-12-20 16:36:02 | 309 hits
38 it 대기업 노리는데말이야... [0] 1 2024-12-20 15:32:47 335
1 | 2024-12-20 15:32:47 | 335 hits
37 있잖아..... [0] 1 2024-12-20 15:31:27 336
1 | 2024-12-20 15:31:27 | 336 hits
36 4년제 대졸 출신 경력 4년차 최종연봉 2400 [0] ㅁㄹ 2024-12-20 15:29:20 320
ㅁㄹ | 2024-12-20 15:29:20 | 320 hits
35 프로그램 시써봤음 ㅎㅎ [0] 1 서정코더 2024-12-20 15:26:45 304
서정코더 | 2024-12-20 15:26:45 | 304 hits
34 컹커러가 다 좋은데 [0] TheProdigy 2024-12-20 15:24:34 320
TheProdigy | 2024-12-20 15:24:34 | 320 hits
33 여기 이 문제 풀수있는사람 있냐? [0] ㅇㅇ 2024-12-20 15:23:27 309
ㅇㅇ | 2024-12-20 15:23:27 | 309 hits
32 닭 8마리와 오리 8마리를 자가교배시켜서 얻을 수 있는 세끼들의 수는? [0] 고정닉없다고 2024-12-20 15:22:20 317
고정닉없다고 | 2024-12-20 15:22:20 | 317 hits
31 형들 연봉협상에 대해서 하나만 물어보자 [0] ㅁㅁㅁㅁㅁㅁㅁ 2024-12-20 15:20:10 346
ㅁㅁㅁㅁㅁㅁㅁ | 2024-12-20 15:20:10 | 346 hits
30 프로그래밍 대학생부터 시작하면 [0] 턱별시 2024-12-20 15:19:03 341
턱별시 | 2024-12-20 15:19:03 | 341 hits
29 밀린월급 1개월반 시발 [0] 북극레밍 2024-12-20 15:17:56 344
북극레밍 | 2024-12-20 15:17:56 | 344 hits
28 cpu 마비기능.code [0] ㅇㅇ 2024-12-20 15:16:49 314
ㅇㅇ | 2024-12-20 15:16:49 | 314 hits
27 회사 화장실에 비데잇으면 존나 빡치지 않냐? [0] ㅇㅇ 2024-12-20 15:15:43 307
ㅇㅇ | 2024-12-20 15:15:43 | 307 hits
26 작년 추석때도 없었던 보너스를 받으니까 기분이 이상하다. [0] ㅇㅇ 2024-12-20 15:13:33 314
ㅇㅇ | 2024-12-20 15:13:33 | 314 hits
25 프로그래밍 아무것도 모르는데 [0] 12 2024-12-20 15:10:19 324
12 | 2024-12-20 15:10:19 | 324 hits
24 자바가 진짜 커피냐 [0] 바나나킥 2024-12-20 15:08:09 328
바나나킥 | 2024-12-20 15:08:09 | 328 hits
23 요즘 it로 창업하기 힘들지?? [0] 바나나킥 2024-12-20 15:05:59 305
바나나킥 | 2024-12-20 15:05:59 | 305 hits