728x90
반응형
<!-- src/main/webapp/20220401/windowex3.html -->
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>새창 열기</title>
</head>
<body>
<a href="javascript:open_win1()">새창 열기</a><br>
<a href="javascript:open_win2()">windowex1.html 페이지 열기</a><br>
<a href="javascript:close_win()">새창 닫기</a><br>
<hr>
<form name="f" method="post">
아이디:<input type="text" name="id"><br>
비밀번호:<input type="password" name="pw"><br>
<input type="button" value="로그인창" onclick="open_win3()">
<script type="text/javascript">
function open_win3() {
nw3 = open("inputex1.html", "input", "width=600, height=200, menubar=no, top=200, left=200");
//현재창의 id와 pw값을 nw3 페이지에 전달
//nw3.onload : nw3 윈도우가 로드가 완료되면,
nw3.onload = function() {
//document.f.id.value : 현재 페이지의 아이디 입력값
//nw3.document.f.id.value : inputex1.html 페이지의 아이디값으로 저장
nw3.document.f.id.value = document.f.id.value
nw3.document.f.pw.value = document.f.pw.value
}
}
function open_win2() {
nw2 = open("windowex1.html", "win", "width=600, height=200, menubar=no, top=200, left=200");
}
function open_win1() {
/*
open 함수 : 새창을 띄워주는 함수
open("새창에 url정보", "새창이름", 옵션)
nw : 새창의 window객체
*/
nw = open("", "open", "width=600, height=200, menubar=no, top=200, left=200");
nw.document.write("새로운 윈도우 창입니다.<br>")
nw.document.write("windowex3.html 페이지의 open 함수로 열린 창입니다.<br>")
}
function close_win() {
nw.close() //새창 닫음
nw2.close()
self.close() // 현재창 닫음
}
</script>
</body>
</html>
728x90
반응형