본문 바로가기

잡단한것들/코딩연습장

팝업

오픈

<!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>Document</title>
</head>
<body>
    <button id="pp" onclick="op()">팝업 오픈</button>

    <script>
        const op = ()=>{
            window.open('test2.html','op','width=700,height=500,scrollbars=0,toolbar=0,menubar=no')
        }
    </script>
</body>
</html>

클로즈

<!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>Document</title>
</head>
<body>
    <h1>팝업!!!</h1>
    <button id="pp" onclick="op()">팝업 닫기</button>

    <script>
        const op = ()=>{
            self.close();
            opener.location.href = 'https://www.naver.com'
        }
    </script>
</body>
</html>