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

프로그래밍 >

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

프로그래밍 프로세스

스레드 작성
373 프갤형들 도움! [0] 123213 2025-02-26 14:47:53 134
123213 | 2025-02-26 14:47:53 | 134 hits
372 기차타고 내려가는데 한정거장 지나쳤다. [0] 생각놀이 2025-02-26 14:46:02 153
생각놀이 | 2025-02-26 14:46:02 | 153 hits
371 와 이번에 졸업반이라서 취업사이트 눈팅 졸라게 하는데... [0] 2025-02-26 14:41:56 170
| 2025-02-26 14:41:56 | 170 hits
370 교수님이 임베디드 아니면 웹하래요 ㅠㅠ [0] 요미코번역인 2025-02-26 14:40:09 160
요미코번역인 | 2025-02-26 14:40:09 | 160 hits
369 자바 극혐 동영상 [0] DART 2025-02-26 14:38:15 185
DART | 2025-02-26 14:38:15 | 185 hits
368 임베디드에서 객체지향이 안돌아간다는건 뭔 개소린가여 [0] ㅇㅇ 2025-02-26 14:22:29 141
ㅇㅇ | 2025-02-26 14:22:29 | 141 hits
366 근데 솔직히 나도 요즘은 헷갈림 [0] 프갤럼 2025-02-26 14:17:53 150
프갤럼 | 2025-02-26 14:17:53 | 150 hits
365 내가 다시 대학생때로 돌아갔음 좋겠다 [0] 북극레밍 2025-02-26 14:15:20 182
북극레밍 | 2025-02-26 14:15:20 | 182 hits
364 전자갈까 컴공갈까 [0] 2025-02-26 14:13:24 158
| 2025-02-26 14:13:24 | 158 hits
363 어디서 부터 변절됬는지 모르겠지만 임베디드란 [0] 프갤럼 2025-02-26 14:11:20 169
프갤럼 | 2025-02-26 14:11:20 | 169 hits
362 횽드라 정보처리기사 [0] ㅇㅇ 2025-02-26 14:09:06 157
ㅇㅇ | 2025-02-26 14:09:06 | 157 hits
361 퇴사 기념으로 휫자좀 .. [0] 북극레밍 2025-02-26 14:05:13 156
북극레밍 | 2025-02-26 14:05:13 | 156 hits
360 서정코더의 프로그램 시 "코드짜는 꿈"을 디버깅 해봤다 [0] 에어로홍 2025-02-26 14:03:15 155
에어로홍 | 2025-02-26 14:03:15 | 155 hits
359 나 입학할 학교에 커뮤니티 만드려고하는데 [0] 2025-02-26 14:01:15 167
| 2025-02-26 14:01:15 | 167 hits
358 임베디드 이야기 [0] 생각놀이 2025-02-26 13:59:22 178
생각놀이 | 2025-02-26 13:59:22 | 178 hits
357 군대안에서 공부할수있는 기초? 책? 뭐가좋을까.. [0] 흐린바다 2025-02-26 01:17:32 172
흐린바다 | 2025-02-26 01:17:32 | 172 hits
356 맥 어드레스 주소 말이야 [0] 궁금해 2025-02-26 01:15:39 150
궁금해 | 2025-02-26 01:15:39 | 150 hits
355 아 시급 이만원됐다 [0] 병1신사냥꾼 2025-02-26 01:13:42 129
병1신사냥꾼 | 2025-02-26 01:13:42 | 129 hits
354 형들 프로그래밍 초보 독학 질문점할게.. [0] 가글 2025-02-26 01:11:50 143
가글 | 2025-02-26 01:11:50 | 143 hits
353 근데 여기갤러리는 어떤사람들이 옴 ?? 직장인? [0] ㅇㅇ 2025-02-26 01:09:48 167
ㅇㅇ | 2025-02-26 01:09:48 | 167 hits