Menu



Manage

파일 목록
Study_Web > 이후/ex10-2.html Lines 36 | 1.2 KB
다운로드

                        <!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>윈도우 닫기</title>
    <script>
        let newWin = null; // 새로 연 윈도우 기억
        function load(URL) {
            newWin = window.open(URL, "myWin", "left=300,top=300,width=400,height=300");
        }
        function closeNewWindow() {
            if (newWin == null || newWin.closed) // 윈도우가 열리지 않았거나 닫힌 경우
                return; // 윈도우가 없는 경우 리턴 
            else
                newWin.close(); // 열어 놓은 윈도우 닫기
        }
    </script>
</head>

<body>
    <h3>window의 close()로 윈도우 닫기</h3>
    <hr>
    <a href="javascript:load('http://www.disneyworld.com')">
        새 윈도우 열기(디즈니월드)</a><br>
    <a href="javascript:window.close()">
        현재 윈도우 닫기</a><br>
    <a href="javascript:closeNewWindow()">
        새 윈도우 닫기</a><br>
    <a href="javascript:load('ex10-5.html')">
        윈도우 크기 조절</a>
</body>

</html>