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

프로그래밍 >

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

프로그래밍 프로세스

스레드 작성
352 IT 코더들의 최대 장점 [0] 윈윈 2025-02-26 01:07:04 195
윈윈 | 2025-02-26 01:07:04 | 195 hits
351 핏도적 쟤 저러는거 그냥 냅둬라... 정신적 방어기제 발동중인거다. [0] 2025-02-24 12:29:10 171
| 2025-02-24 12:29:10 | 171 hits
350 특정 시간임을 입증할 방법을 물어보겠음 [0] dot 2025-02-24 12:28:14 191
dot | 2025-02-24 12:28:14 | 191 hits
349 프갤 입갤해도 되나요? [0] 눈꽃❄ 2025-02-24 12:25:30 167
눈꽃❄ | 2025-02-24 12:25:30 | 167 hits
348 배열 안에서 최대값 찾아내는 함수 [0] 꾸꾸까까 2025-02-24 12:23:02 190
꾸꾸까까 | 2025-02-24 12:23:02 | 190 hits
347 3/12 징병검사 [0] 백이 2025-02-24 12:16:42 155
백이 | 2025-02-24 12:16:42 | 155 hits
346 핏도적 님 맨날 여기 계신데 프로그래밍 하긴 하세요? [2] 2025-02-24 11:59:00 160
| 2025-02-24 11:59:00 | 160 hits
345 프리 시작했는데, 언제부터 돈 들어오냐? [0] 1 안뇽 2025-01-15 15:28:48 168
안뇽 | 2025-01-15 15:28:48 | 168 hits
340 Ruby 충새끼들은 대대손손 Ruby만 쓰시기 바랍니다. [1] ㅁㄴㅇㄹ 2025-01-14 13:27:11 186
ㅁㄴㅇㄹ | 2025-01-14 13:27:11 | 186 hits
339 당신의 뒷조사를 할때 사용되는 안드로이드폰(맛폰으로 보세요, 엑박이면 X표시를 클릭) [0] ㅇㅇ 2025-01-14 11:55:32 181
ㅇㅇ | 2025-01-14 11:55:32 | 181 hits
172 프갤럼들의 웹땔감드립이 존나말도안되는 증거 [0] 2024-12-31 14:58:05 242
| 2024-12-31 14:58:05 | 242 hits
171 화장품 연구원아 너 남자냐 여자냐 [0] 1 2024-12-31 14:36:57 268
1 | 2024-12-31 14:36:57 | 268 hits
170 gpl 소스코드 공개의무는 그걸 배포했을때 생기는거다 [0] ㅇㅇ 2024-12-31 14:15:49 269
ㅇㅇ | 2024-12-31 14:15:49 | 269 hits
169 노트북이나 아이패드 사고싶은 컴공1학년아 [0] 불고기브라더 2024-12-31 13:54:12 283
불고기브라더 | 2024-12-31 13:54:12 | 283 hits
168 국비IT 수료의 장단점 [0] 1 2024-12-31 13:33:02 287
1 | 2024-12-31 13:33:02 | 287 hits
167 비트컴터학원 전공자 출신만 뽑는거 아니었냐? [0] 불고기브라더 2024-12-31 13:11:54 267
불고기브라더 | 2024-12-31 13:11:54 | 267 hits
164 전 C언어 9년차 프로그래머입니다 [0] 2024-12-31 07:34:16 237
| 2024-12-31 07:34:16 | 237 hits
163 오늘도 스~ 연발 ㄷㄷ [0] 매직개더링 2024-12-31 07:13:08 254
매직개더링 | 2024-12-31 07:13:08 | 254 hits
161 님들 지금당장 카톡 만들라고하면 만들 수 있어요? [0] ㅇㅇ 2024-12-30 21:01:55 281
ㅇㅇ | 2024-12-30 21:01:55 | 281 hits
160 화장품 연구원을 보니 옛 생각이 나서 아련해진다 [0] 1 2024-12-30 20:40:46 266
1 | 2024-12-30 20:40:46 | 266 hits