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

프로그래밍 >

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

프로그래밍 프로세스

스레드 작성
545 하루죙일 영어공부만 하니까 졸라 질린다 [0] ㅁㄴㅇㅁㄴㅇ 2025-03-11 07:19:25 80
ㅁㄴㅇㅁㄴㅇ | 2025-03-11 07:19:25 | 80 hits
544 씨발 나한테 유포리아보라고 댓글단새끼 [0] 黑猫 2025-03-11 04:12:35 80
黑猫 | 2025-03-11 04:12:35 | 80 hits
543 백신 뭐 써요?? [0] dd 2025-03-11 02:39:05 62
dd | 2025-03-11 02:39:05 | 62 hits
542 프갤럼들한테 배울게있나? [0] 북극레밍 2025-03-11 01:05:44 77
북극레밍 | 2025-03-11 01:05:44 | 77 hits
541 책값이 후덜덜하구만. [0] 불고기브라더 2025-03-10 23:32:03 44
불고기브라더 | 2025-03-10 23:32:03 | 44 hits
540 몇가지 질문좀요 [0] ㅇㅇ 2025-03-10 21:58:26 74
ㅇㅇ | 2025-03-10 21:58:26 | 74 hits
539 비쥬얼스튜디오 2013버전인데 이걸로 10버전교재 대신해도되나요? [0] 2025-03-10 17:16:18 41
| 2025-03-10 17:16:18 | 41 hits
538 컴공 힘들다 힘들다 하는게 [0] ㅁㄴㅇ 2025-03-10 15:42:41 33
ㅁㄴㅇ | 2025-03-10 15:42:41 | 33 hits
537 이곳이 만약 이걸 인증한다면? [0] Dssafhjrfv 2025-03-10 14:09:03 62
Dssafhjrfv | 2025-03-10 14:09:03 | 62 hits
536 '안녕하세요' 젖꼭지 집착녀 "안 만지면 불안해" [0] 에어로홍 2025-03-10 12:35:39 42
에어로홍 | 2025-03-10 12:35:39 | 42 hits
535 C / C++ / OpenCL 이 3가지 용 교재 추천좀해주세요 [0] ㅇㅇ 2025-03-10 11:01:57 56
ㅇㅇ | 2025-03-10 11:01:57 | 56 hits
534 프로그래밍은 레알 취미로만 해야하나요? [0] 턱별시 2025-03-10 09:28:24 59
턱별시 | 2025-03-10 09:28:24 | 59 hits
533 포인터를 통한 간접접근 좀 물읍시다 형들 [0] 카운터블 2025-03-10 07:54:59 63
카운터블 | 2025-03-10 07:54:59 | 63 hits
532 형들 나 KITRI에서 하는 교육있잖아. [0] 무적정비 2025-03-10 06:21:32 44
무적정비 | 2025-03-10 06:21:32 | 44 hits
531 디시갤러리 중에 프갤은 참 좋은 곳인데 [0] 딸기괴담 2025-03-10 04:48:01 63
딸기괴담 | 2025-03-10 04:48:01 | 63 hits
530 HashMap의 value를 다시 HashMap으로 받는 경우 [0] ㅇㅇ 2025-03-10 03:14:26 54
ㅇㅇ | 2025-03-10 03:14:26 | 54 hits
529 국비지원으로 it개발자되는거는 학원에좋은거같다 [0] ㅇㅇ 2025-03-10 00:07:52 61
ㅇㅇ | 2025-03-10 00:07:52 | 61 hits
528 삼전 연구개발직이면 [0] 2025-03-09 22:33:46 73
| 2025-03-09 22:33:46 | 73 hits
527 으어어어 c++ 문자열에 취한다 ㅡ아어어 [0] ㅇㅇ 2025-03-09 19:26:42 126
ㅇㅇ | 2025-03-09 19:26:42 | 126 hits
526 포샵 잘하는 게이 있냐? [0] ㅁㄴㅇ 2025-03-09 16:19:28 60
ㅁㄴㅇ | 2025-03-09 16:19:28 | 60 hits