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 {} 






ㅁㄴㅇㅁㄴㅇㅁㄴㅇㅁㄴㅇㅁㄴㅇ