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

프로그래밍 >

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

프로그래밍 프로세스

스레드 작성
21 님들 개인창작물들 있죠?? ㄹㅇ 부러움 ㅜㅜ 나도 컴잘하고시픔 [0] ㅇㅇ 2024-12-20 15:03:41 336
ㅇㅇ | 2024-12-20 15:03:41 | 336 hits
20 까톡 봇 만들기 어려울까? [0] kiacw 2024-12-20 15:02:34 332
kiacw | 2024-12-20 15:02:34 | 332 hits
19 게임하고싶은데 돈이 없다아아 [0] 북극레밍 2024-12-20 15:01:27 333
북극레밍 | 2024-12-20 15:01:27 | 333 hits
18 근데 노동청에 신고때리면 돈은 어떻게되는거얌? [0] 북극레밍 2024-12-20 15:00:21 356
북극레밍 | 2024-12-20 15:00:21 | 356 hits
17 임베디드 리눅스할려면 리눅스알아야하나요? [0] dqwq 2024-12-20 14:59:14 311
dqwq | 2024-12-20 14:59:14 | 311 hits
16 비트코인으로 돈번 썰 (스압) [0] 응딩이 2024-12-20 14:58:07 327
응딩이 | 2024-12-20 14:58:07 | 327 hits
15 출동! 오토봇! [0] 김자동 2024-12-18 14:33:10 318
김자동 | 2024-12-18 14:33:10 | 318 hits
12 IT에 대해 제대로 알려주겠다. [0] 개발자 2024-12-13 14:09:22 306
개발자 | 2024-12-13 14:09:22 | 306 hits
10 안녕하세요, 컴공진학 희망하는 급식이 입니다. [1] 3 프린이 2024-10-22 13:39:09 339
프린이 | 2024-10-22 13:39:09 | 339 hits
9 광주 사는 앱쟁이 입니다. [2] 1 앱마스터 2024-10-19 21:12:20 364
앱마스터 | 2024-10-19 21:12:20 | 364 hits