<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<script type="text/javascript">
function func1() {
window.open("", "", "width=300,height=300");
}
function func2() {
window.open("http://www.naver.com", "창이름", "width=600,height=600,scrollbars=yes");
}
function func3() {
window.close();
}
function func4() {
window.open("test4_1.html", "창이름", "width=400,height=400");
}
</script>
</head>
<body>
<input type="button" value="창 열기 1" onclick="func1()"><br>
<input type="button" value="창 열기 2" onclick="func2()"><br>
<input type="button" value="창 닫기" onclick="func3()"><br>
<input type="button" value="test4_1.html 창 열기" onclick="func4()"><br>
</body>
</html>
연습
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<script type="text/javascript">
function windowClose() {
window.opener.alert("새 창을 닫았습니다.");
window.close();
}
</script>
</head>
<body>
<h1>Javascript - test4_1.html</h1>
<input type="button" value="창 닫기" onclick="window.close()"><br>
<input type="button" value="창 닫기 및 알림 표시" onclick="windowClose()">
</body>
</html>